Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
| ReportDate | Sales |
| 1/1/2022 | 61 |
| 1/2/2022 | 86 |
| 1/3/2022 | 64 |
| 1/4/2022 | 69 |
| 1/5/2022 | 62 |
| 1/6/2022 | 96 |
| 1/7/2022 | 64 |
| 1/8/2022 | 60 |
| 1/9/2022 | 71 |
| 1/10/2022 | 79 |
| 1/11/2022 | 69 |
| 1/12/2022 | 73 |
The requirement is to get the average sales of the biggest two month in the last six months.
Solved! Go to Solution.
Hi,
In case you do not have a calendar table, please try below.
Please check the below picture and the attached pbix file.
Expected result measure: =
VAR _currentmonthend =
EOMONTH ( MAX ( Data[ReportDate] ), 0 )
VAR _sixmonthboforestart =
EOMONTH ( MAX ( Data[ReportDate] ), -6 ) + 1
VAR _sixmonthsperiodtable =
CALCULATETABLE (
Data,
Data[ReportDate] >= _sixmonthboforestart,
Data[ReportDate] <= _currentmonthend
)
VAR _biggesttwovaluesavg =
AVERAGEX ( TOPN ( 2, _sixmonthsperiodtable, Data[Sales], DESC ), Data[Sales] )
RETURN
_biggesttwovaluesavg
It works well. Thank you Jihwan.
Hi,
In case you do not have a calendar table, please try below.
Please check the below picture and the attached pbix file.
Expected result measure: =
VAR _currentmonthend =
EOMONTH ( MAX ( Data[ReportDate] ), 0 )
VAR _sixmonthboforestart =
EOMONTH ( MAX ( Data[ReportDate] ), -6 ) + 1
VAR _sixmonthsperiodtable =
CALCULATETABLE (
Data,
Data[ReportDate] >= _sixmonthboforestart,
Data[ReportDate] <= _currentmonthend
)
VAR _biggesttwovaluesavg =
AVERAGEX ( TOPN ( 2, _sixmonthsperiodtable, Data[Sales], DESC ), Data[Sales] )
RETURN
_biggesttwovaluesavg
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 9 | |
| 6 | |
| 5 |
| User | Count |
|---|---|
| 27 | |
| 22 | |
| 19 | |
| 17 | |
| 11 |