Although the application of a DAX measure is sometimes limited in the application of a table or a value, its possible to make the same measure work in both applications. The benefits of this is that you only need to create one measure rather than two.

Both of these screenshots are using the same measure in a card visualisation,
In this application, I've got a sales table with the following information.
Then to create the measure that will dynamically change depending on the application you'll need to create a measure with the following DAX code:
DynamicSum =
VAR ReturnIfTable = "Please Select a single date from the table on the left"
VAR ReturnIfValue =
"You have selected " & MAX ( SalesData[Date] ) & " and the total sold on that date was "
& SUM ( SalesData[Number Sold] )
RETURN
IF (
MIN ( SalesData[Date] ) = MAX ( SalesData[Date] ),
ReturnIfValue,
ReturnIfTable
)
VAR ReturnIfTable = "Please Select a single date from the table on the left"
VAR ReturnIfValue =
"You have selected " & MAX ( SalesData[Date] ) & " and the total sold on that date was "
& SUM ( SalesData[Number Sold] )
RETURN
IF (
MIN ( SalesData[Date] ) = MAX ( SalesData[Date] ),
ReturnIfValue,
ReturnIfTable
)
Then once this code is added to the card, it will change its output when there is a single data selected and return information relating to just that date.
Comments
Post a Comment