Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I need to show the previous months sales broken down by day. So last month on this day total sales was X.
Problem is the DAX calculate function is agregating sales of the entire month together, which isnt what I want.
Left one is showing correct when drilled by month, Right one is incorrect when drilled into day ( should show the sales amount for the same day last month)
DAX calc used
PreviousMonthSales = CALCULATE(SUM(Sales[TotalRev]),PREVIOUSMONTH('Date'[Date]))
I couldn't find any similar question asked in the past, which I thought was quite odd. ANy Help is appreciated,
Solved! Go to Solution.
Try using the DATEADD() function.
=CALCULATE( [Total Sales], DATEADD('Calendar'[Date],-1,MONTH) )
It won't aggregate the previous period.
The problem is if the previous month doesn't have that day, it will repeat the last day of the month. So, if you are using that measure for March 29, 30, and 31, they will all report Feb 28. You would need to add some IF() logic to it to mask that if it is an issue.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingTry using the DATEADD() function.
=CALCULATE( [Total Sales], DATEADD('Calendar'[Date],-1,MONTH) )
It won't aggregate the previous period.
The problem is if the previous month doesn't have that day, it will repeat the last day of the month. So, if you are using that measure for March 29, 30, and 31, they will all report Feb 28. You would need to add some IF() logic to it to mask that if it is an issue.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingThis is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
81 | |
75 | |
60 | |
37 | |
33 |
User | Count |
---|---|
102 | |
56 | |
52 | |
45 | |
40 |