Skip to content

Dynamic Headings for a DAX Visualisation

>> Download the sample (Power BI)

This sample creates a dynamic heading for a DAX visualisation, for example to show the highest sales made over a particular time period.

Highest Month Sales =
MAXX ( VALUES ( Calendar_Table[Month & Year] ), [SUMX Total Sales] )
Highest Month Text =
"The Highest Sale Month in the selected date context is "
& FORMAT ( [Highest Month Sales], "$0,000" )
Last Sale Period =
VAR LastSale =
CALCULATE ( MAX ( Sales_Table[Date] ), ALLSELECTED ( Sales_Table ) )
RETURN
IF (
DATE ( YEAR ( LastSale ), MONTH ( LastSale ), 1 )
= DATE ( YEAR ( MAX ( Calendar_Table[Date] ) ), MONTH ( MAX ( Calendar_Table[Date] ) ), 1 ),
1,
0
)
SUMX Total Sales =
SUMX ( Sales_Table, Sales_Table[Quantity] * Sales_Table[Unit Price] )
Calendar_Table =
GENERATE (
CALENDAR ( DATE ( 2017, 1, 1 ), DATE ( 2019, 12, 31 ) ),
VAR currentDay = [Date]
VAR Day =
DAY ( currentDay )
VAR Month =
MONTH ( currentDay )
VAR Year =
YEAR ( currentDay )
RETURN
ROW ( "Day", day, "Month", month, "Year", year )
)