can't figure out how to assign column from Dim table to measures group - tsql

DW is written in foreign language so i translated it on pictures.
It is about some facility where you can rent rooms and equipment.
In Fact table i have one measure column which represents number of reservations and it works as expected, problem is in DimPayment table i have columns PaymentSum and PaymentSumWDiscount which i would need to use as measures. i tried to do something in calculations tab but i only get null values
I can't figure out how to use columns PaymentSum and PaymentSumWDiscount
as measures
i tried to do something in calculations tab but i only get null values

JOIN the FactReserving table to the DimPayment table in the Data Source View and then you can access those two columns in the Measure group.

It looks like you want to use your Dimension attributes as measure.
One way to achieve this is to make your Dimension table as a Measure Group as well.
The following example works with the AdventureWorks sample to create a measure group for the Product table:
In Visual Studio / SSDT, open your Cube, create a new Measure Group and select your table. (for your scenario, it would be the DimPayment table).
Your dimension usage mapping for this would be 'Fact' as both your fact and dimension are in the same table.
Now, you should be able to use the measures normally.
All the numeric fields automatically added as measures:
Using it as a measure:

Related

how to create table to hold measures in SSAS tabular cube

I want to create an empty table in a SSAS tabular cube (in SSDT, in Visual Studio) to hold all of my cube's measures. In Power BI Desktop, I would do so by creating a 1-column "empty" table in Power Query, loading it into the model, put 1 measure on it, go back into Power Query, delete the empty column, re-load the model, and continue putting measures on the table. But, I don't see an option to do this in SSDT (in Visual Studio) without using a calculated table. Is this possible? If so, how?
You don't want to do that. If the table has no columns, you won't be able to see the measures in Visual Studio:
I would create a one column table using the DAX formula ={""} and hide the column in the model and not worry about it.
If you want to name the column and have no rows, you can use this more obscure formula:
=TOPN(0, ROW("Column", ""))
Picking up (and perhaps simplifying) TheRizza's excellent idea - for which thanks - I used this:
You can obviously (I presume) create as many columns as you like. I tried putting a measure in the second column, then removing this from the table calculation formula, and SSAS moves the measure back into the first column (so you don't lose it).

How can I create filters on a series of tables where the final table yields a single data observation?

I am creating an interactive 'calculator' using tableau. I have a series of dataframes that I have crossed with one another, such that the resulting dataframe is every possible combination between the tables, and every row is unique.
Each column is its own worksheet as a table. Each table in the dashboard is a pane. So, here we have a series of tables with selectable units of measurement, and the final pane on the dashboard should filter to the cell for its respective column, on the unique row of the dataset that the user has selected and 'filtered out'.
I'm having some issues getting this to work and not sure why.
The closest I can think to solving this would be 'Cascading Filters.' Here are a couple resources:
General Use
In dashboard action-filter form
The critical piece, however, is that the filters must be selected in a specific order - therefore making them 'cascading.' This may differ from your presumed concept of clicking/filtering in any order on the worksheets to then arrive to a final answer. I do think that this may be a limitation of Tableau - I don't think that a 'many to many' type of relationship can be set up within Action Filters.

Tableau table filter for one column only in table

I have a really basic question that I can't figure out. I need to create a table that has multiple calculated fields, but I need only one of the calculated fields to be filtered for a specific dimension value. For example, I have the following data set (dummy data) and I want to create a table that will include total clicks for both companies, but [cost per click] from one company only, company B.
DATA SET
Company| Clicks| $ Cost
------------------------
Comp A | 100 | $20
Comp B | 200 | $40
WHAT I'M LOOKING FOR
CLICKS | COST/CLICK
TOTAL 300 | $0.13
$0.13 comes from 40/300; $40 from company B and 300 clicks from both company A and B.
How do you create a table that has multiple calculations but with one of those calculations filtered on one dimension value only?
One simple calculated field:
sum(if [Company] = 'B' then [Cost] end )/sum([Click])
This should get you in the right direction.
Based on your question and your comment, you want to divide the cost by the TOTAL number of clicks in your dataset.
Create a calculated field called "TotalClicks" and enter this formula
window_sum(sum([Clicks])) // This formula will sum the clicks field for all rows
Create a calculated field called Cost / Clicks and enter this formula
sum([Cost]) / [TotalClicks]
Add the Cost / Clicks field to the sheet and it should look like this
NOTE: If you need to partition / group your report, you may have to play around with this some. I don't use window functions within tableau very often since I usually handle the aggregation at the datasource level instead.
NOTE: Since you mentioned filtering, I will add this statement -- If you filter out any of your data, that data will not (cannot) be included in any calculated fields (To the best of my knowledge and experience, anyway). If you need to include that data (total clicks), I think the only option is to add that aggregated total to your dataset - otherwise, tableau can't calculate it if you are filtering it out.
Edit2: If you cannot change the underlying dataset, you could accomplish this by creating another datasource and joining it to your inital data source --
Data > Add Datasource, add the datasource again and change the name so you can identify it
Click Data > Edit Relationships. Click Custom and REMOVE any linked fields -- this will essentially produce a Cartesian join (every record in your first DataSource will have every reocrd from your second Datasource)
Select the second datasource and create a calculated field (ClicksTotal_DS2) using the same window_sum function
Select the first datasource and create a calculated field (named Cost / Clicks_DS2) using this formula
sum([Cost])/ [Sheet1 (test) (2)].[ClicksTotal_DS2]
Now you can apply a filter to your first data source, and your second data source will still calculate the total.

Tableau table hides categories with no data - how to prevent?

I have Tableau report where I am showing data by category in columns.
The table shows all columns when there is no filter on data. But when filter is applied, some of the categories do not have data, so table shrinks, hiding columns without data
Is there a way to always show columns regardless of data or not in that column?
Please see screenshots below.
Go to Analysis >Table layout> Show columns with no data or
Analysis>Table layout>Show rows with no data
The next step depends on whether your "disappearing" fields are dimensions or measures.
If you want to force the display of members for specific dimensions, then one (kind of complex) solution is to use an advanced Tableau feature called data blending to force the existence of dimension members, even if there are no related measure values. The trick is to make a simple data source, say a text file, that lists the members of each dimension. Use that source as the primary data source, and make the original data source the secondary source.
Go to Analysis >Table layout> Show columns with no data or Analysis>Table layout>Show rows with no data
Also You can right click on header and select show missing values if you are using line chart.
Solution 1: (When you’re working with Dates or Numeric bins)
Right click on the numerical or Date column to extrapolate the missing values. As you notice in the lower part of the screenshot, this will not work on Categorical data !
Solution 2: Categorical Data
As indicated in the accepted answer, Analysis > Table Layout > Show Empty Rows will get you the same result for Categorical (Text) Data
Solution 3: Calculated Columns
If for some reason, none of the 2 above point & click solutions work, you can create calculated columns to calculate the measure for each of the Categories with the below formula and then line them up on the Columns to achieve the same result
Profit (Category 1)
IF MyColumn = "Category 1" THEN
Profit
ELSE
NULL
END
Profit (Category 2)
IF MyColumn = "Category 2" THEN
Profit
ELSE
NULL
END
Not the most convenient solution when you have hundreds of unique values in your column, but nevertheless a workaround !

Joining two datasets to create a single tablix in report builder 3

I am attempting to join two datasets in to one tablix for a report. The second dataset requires a personID from the first dataset as its parameter.
If i preview this report only the first dataset is shown. but for my final result what i would like to happen is for each row of a student there is a rowgrouping (?) of that one students modules with their month to month attendance. Can this be done in report builder?
The best practice here is to do the join within one dataset (i.e. joining in SQL)
But in cases that you need data from two separate cubes(SSAS) the only way is the following:
Select the main dataset for the Tablix
Use the lookup function to lookup values from the second dataset like this:
=Lookup(Fields!ProductID.Value, Fields!ID.Value, Fields!Name.Value, "Product")
Note: The granularity of the second dataset must match the first one.
We had a similar issue and that can be resolved this way.
First of All, ensure the first data set's query and second data set's query are working fine by executing separately on the Database client tool such as Datastudio.
Build two data sets on SSRS tool with the respective queries and make sure both the data sets have same key column (personID).
On the SSRS report design, create a table from tool box and add the required columns from the first data set along with the matching key column(personID). Add a new column and use look up function to get the required column from the other data set against the same key column (personID).