Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowData Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more
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 out the month name and year of the month with the lowerst value of [Avg Premium].
I wrote the below measure, and its retrurning a value on the line with the month (2/22) with the lowest value of [Avg Premium], but Accouting month name and year are returning as 12(Dec) & 23, which is not even selected in the visual the MAXX statement is iterating though.
I need to figure out how to return the value of the accounting month and year on the line with the lowest value of the Avg Premium Measure.
Solved! Go to Solution.
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
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
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...
Thank you so much! This works well.
Hi @mjanecek ,
I tried to replicate your usecase. Please find a suggestion below.
My data model
Formula Average
Average | Value = AVERAGE('Fact_Sales'[Values])
Formula Monthly Min Period
Iterator | Period with Min Value =
var _current = [Average | Value]
var _MonthlyMinValue =
CALCULATE(
MINX(
VALUES(DimDate[MonthWithYear]),
CALCULATE([Average | Value])
),
ALLSELECTED(DimDate)
)
Return
IF(_current=_MonthlyMinValue,SELECTEDVALUE(DimDate[MonthWithYear]))
Result
Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.
Hi: This works great when there is a month on a visual, but when I try to put it into a scorecard, I get no value. How would I adapt the measure to allow the max month and year to display in a scorecard that did not have the month and year in the filter context.
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 23 | |
| 21 | |
| 20 | |
| 18 | |
| 13 |
| User | Count |
|---|---|
| 58 | |
| 50 | |
| 38 | |
| 31 | |
| 27 |