Forum Discussion
Slice Facts based on UI events
Folks:
I have a problem that I have recreated in the attached .pbix file. This file contains only AdventureWorks data.
AdventureWorks data can be looked at based on OrderDate, DueDate or ShipDate. (Only one of these dates can be related to DimDate. In my model it is OrderDate. The other two relationships are inactive.)
If you look at the UI – I have a slicer where you can change the particular date you want to use to look at the data. The slicer works. The table view above the slicer will change as you click on various buttons.
So – in my model on FactInternetSales – I have defined a new column with the following formula:
FocusDate = if(
selectedvalue(DateFocus[ID]) = 1,
FactInternetSales[OrderDate],
if (
selectedvalue(DateFocus[ID]) = 2,
FactInternetSales[DueDate],
FactInternetSales[ShipDate]
)
)
The formula does populate the field initially – with ship date in this case.
The axis of the chart in the UI is FocusDate. So the chart is interfacing with that column.
Here is the problem. When I change the value of the slicer – I expect contents of the calculated column in the data model to change – thus causing the graph to change slightly. That is not happening. Every time I go into the data model – the value of the FocusDate field is ship date.
What am I doing worong????
7 Replies
- dedelman_clng
Community Champion
Calculated columns are populated once, at the time of data refresh. You want to take the exact same code and make it into a Measure, which are not set at data refresh and change dynamically.
Hope this helps
David
- AnonymousNot applicable
Hey David:
I did exactly as you suggested. I deleted the column in the data model and attempted to add it as a measure on the FactInternetSales table by cut/pasting the code.
That is giving me an error: A single value for column 'ShipDate' in table 'FactInternetSales' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
I do not wnat to aggrigate anything. What I'm after is more like a case statement then an aggrigate. Is there a way I can refer to current row??
Thank you for the help.
- dedelman_clng
Community Champion
You can apply MIN or MAX to the dates in the formula code without worry as the context for "Current row" will be created by the visual and the measure will be dynamically calculated.