Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi All,
I'm trying to build a formula into dax that calculates the previous months sales depending on which month is selected. For example in the screenshot below i want 'Sales (£) PM' to pull through July sales when August is selected in the Month filter.
The data is at month level therefore a lot of the solutions posted on this forum aren't giving me the desired result, I have attached the calendar table below:
Any help would be massively appreicated!
Thanks,
Matt.
Solved! Go to Solution.
Hi @mes0012 ,
I suggest you to create a DimDate table with continuous date in it and then try PREVIOUSMONTH.
If this reply still couldn't help you solve your issue, please share a sample file with us and show us a screenshot with the result you want.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @mes0012 ,
I suggest you to create a DimDate table with continuous date in it and then try PREVIOUSMONTH.
If this reply still couldn't help you solve your issue, please share a sample file with us and show us a screenshot with the result you want.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Here is one way to do this:
Data:
Relation:
Dax:
Here we remove YearMonth filter context and take the maximum value which is lower than current mont -> last month as context.
Proud to be a Super User!
@ValtteriN, thanks for coming back on this.
I've given the above suggestion a go but i can't get it to work. I created a new table, summarised in the same way as in your suggestion above (Total Debit Balance is the original field name before i've renamed it in the visual):
However, when i build the measure i'm still getting blanks:
Any chance you can see where i've gone wrong from those screenshots?
Thanks,
Matt.
Hi @mes0012 ,
Now that I revisited this I realized that there isn't anything preventing you from using previousmonth like @v-rzhou-msft suggested.
Here is a bit better dax (if you don't want to use PREVIOUSMONTH for one reason or another):
Proud to be a Super User!
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
33 | |
16 | |
13 | |
10 | |
8 |
User | Count |
---|---|
59 | |
20 | |
12 | |
11 | |
10 |