Forum Discussion
mjanecek
3 years agoHelper I
Need Help with Dax
I have a measure (Avg Premium) that is filtered by month for all of 2022. Here is a visual of the months and that measure. I am trying to write a measure that will allow me to pull...
- 3 years ago
You can use a DAX pattern like this to return your max month in a card visual. Update it with your actual table, column, and measure names.
MaxMonth = VAR vSummary = ADDCOLUMNS ( ALLSELECTED ( 'Date'[YearMonthShort] ), "cQty", [Total Qty] ) VAR vTop1 = TOPN ( 1, vSummary, [cQty], DESC ) RETURN MAXX ( vTop1, 'Date'[YearMonthShort] )Pat
ppm1
3 years agoSolution Sage
You can use a DAX pattern like this to return your max month in a card visual. Update it with your actual table, column, and measure names.
MaxMonth =
VAR vSummary =
ADDCOLUMNS ( ALLSELECTED ( 'Date'[YearMonthShort] ), "cQty", [Total Qty] )
VAR vTop1 =
TOPN ( 1, vSummary, [cQty], DESC )
RETURN
MAXX ( vTop1, 'Date'[YearMonthShort] )Pat
mjanecek
3 years agoHelper I
Can you tell me why my sort in the below code is not working right?
EVALUATE
VAR vSummary =
ADDCOLUMNS ( ALLSELECTED ( 'Calendar'[Accounting Month] ), "Prem", [Avg Premium] )
VAR vTop1 =
TOPN ( 10 , vSummary,[Prem],DESC )
VAR vMaxmonth = maxx(vTop1,[Prem])
RETURN vTop1
The premium clearly is not sorting the top 10 values in DESC order. Have not been able to figure out why...