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!View all the Fabric Data Days sessions on demand. View schedule
Dear Experts,
Currently I am comparing two consecutive months in Power Bi.
The current month "Jan-2020" has only 6(1~6) days sales. So,I'd like to compare by the 6(1~6) days sales of "Dec-2019".
But I am getting the whole month sales of "Dec-2019".
If I select "Dec-2019" in slicer, it is working correctly becuase of the whole month sales data for both Nov and Dec.
DAX formulas:
Please help me to fix this.
Solved! Go to Solution.
You are selecting month not date that is the problem
Create a var of day and use <= of that
last MTD Sales =
var _day = day(today)
return
CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)), day(date[date])<= _day)
Move dateadd inside and check
example
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
@amitchandak,
I have moved dateadd inside but the total sales is still getting the whole month of "Dec-2019".
Any other formula to fix this?
You are selecting month not date that is the problem
Create a var of day and use <= of that
last MTD Sales =
var _day = day(today)
return
CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)), day(date[date])<= _day)
I was calculating by day(today()) function and found that
today is "22 Jan 2020" and the calculation was made based on today date.
If I select the "Dec - 2019" in slicer, It only calulate based on today date and sale is 1~22 data only.
Actually it should be calculate based on the whole month for Nov and Dec 2019.
So, I tried by the max date and it become the desire result.
Thank you so much @amitchandak.
Dax Formulas,
Current Month Sales = var _day = DAY(MAX('Calendar'[Date]))
return
CALCULATE([Total Sales],DATESMTD(dateadd('Calendar'[Date],0,MONTH)), day('Calendar'[Date])<= _day)
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!