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
Hi All,
How can i get previous month data based on selected month in DAX query?
tower value = feb 2020 data.
tower previous = previous month data (jan 2020).
For example i selected feb 2020 and i want jan 2020 data also but cant figure out how to calculate in DAX.
Here my table for reference.
Solved! Go to Solution.
Hi @Anonymous ,
I created some data:
Here are the steps you can follow:
1. Create calculated column.
Month_m = MONTH('Table'[Month])MonthYear =
FORMAT('Table'[Month],"mmm")&" "&RIGHT('Table'[Month],2)
2. Create measure.
Tower Previous =
VAR _MONTH=SELECTEDVALUE('Table'[MonthYear])
VAR _Attribute=SELECTEDVALUE('Table'[Attrubute])
var _last=MAXX(FILTER(ALL('Table'),'Table'[MonthYear]=_MONTH),'Table'[Month_m]) -1
return
CALCULATE(SUM('Table'[Tower Value]),FILTER(ALL('Table'),
'Table'[Month_m]=_last&&'Table'[Attrubute]=_Attribute&&'Table'[Category]=MAX('Table'[Category])))
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @Anonymous ,
I created some data:
Here are the steps you can follow:
1. Create calculated column.
Month_m = MONTH('Table'[Month])MonthYear =
FORMAT('Table'[Month],"mmm")&" "&RIGHT('Table'[Month],2)
2. Create measure.
Tower Previous =
VAR _MONTH=SELECTEDVALUE('Table'[MonthYear])
VAR _Attribute=SELECTEDVALUE('Table'[Attrubute])
var _last=MAXX(FILTER(ALL('Table'),'Table'[MonthYear]=_MONTH),'Table'[Month_m]) -1
return
CALCULATE(SUM('Table'[Tower Value]),FILTER(ALL('Table'),
'Table'[Month_m]=_last&&'Table'[Attrubute]=_Attribute&&'Table'[Category]=MAX('Table'[Category])))
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @Anonymous ,
thanks it work but when i put 2021 data it doesn't appear.
can u advice me what i need to do?
HI, @Anonymous
Try this measure
Measure =
CALCULATE(
SUM('Table'[Value]),PREVIOUSMONTH('Dates'[Date] ))
You also need a Calendar Table
@Anonymous Hi
Do you have a relationship between the date table and the data table?
yes both table have relationship
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 |
|---|---|
| 9 | |
| 9 | |
| 8 | |
| 6 | |
| 6 |
| User | Count |
|---|---|
| 20 | |
| 20 | |
| 17 | |
| 14 | |
| 14 |