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 Team,
I am currently using Direct Query i.e SAP HANA as source , some built in functions are no longer working.
I need a measure to calculate previous month variance. These measure should calculate the variance from the latest data avaialbe in the table.
I dont have a date column and I am trying previousmonth whihcis not working is there any way we can get the variance in direct query in power bi without date table created?
I am struck with this issue please help
Sample Data :
score Run_date
52 02/02/2022
63 02/02/2022
44 03/02/2022
55 02/02/2022
Here are my two measures for Current Month and Prior Month PM:
Current Month Score = Average(score )
@amitchandak Thank you for your reply. As per your suggestion i have created a date table and used the above formula but it is returning blank.
I have marked my table as date table.
Please help
Hi @PBILearner2022 ,
If your model has dim date table. please make sure relationship between date table and fact table is one to many and cross filter direction is single. Then use 'Dim Date' table as the first parameter of PREVIOUSMONTH function. The same as PREVIOUSMONTH('Dim Date'[RUN_DATE]).
If your model there is no dim date table, please add some funtion like ALL(),REMOVEFILTER()... to remove date filter on each row context. Please refer the following code:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you @v-chenwuz-msft by using the above measure I am getting the previous month variance , but in my scenario i will be having last 6 months data in that particular data set and I need to display the latest month data and previous month variance alone in a table .
Is there any way I can create flag it as based on max of date in direct query mode in DAX and use it as filter ?
@PBILearner2022 , For this you need a date table
Var PeviousMonths =CALCULATE([Current Month Score],PREVIOUSMONTH(Date[DATE]))
You said that - I dont have a date column - what do you have to get last month ?
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
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 |
|---|---|
| 103 | |
| 80 | |
| 62 | |
| 51 | |
| 45 |