Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi guys, I'm currently want to calculate previous month sale. This is my data table
For some reasons, I dont want to convert the column month into date to use DAX like PREVIOUS or EARLIER. My idea is that to calculate based on the value of the most nearest number, but I dont know how to do this. Please help me to do this, or if you have any greater idea, please share for me.
Best regards,
Nerd
Solved! Go to Solution.
Didn't think about that. Can you not just convert the month to date with DAX in a new column like:
Hi there,
I think it's because of the REMOVEFILTERS() piece. Could you try changing the measure to use the ALLEXCEPT function;
CALCULATE(
SUM(SalesTable[SALES]),
PREVIOUSMONTH(SalesTable[MonthToDateConverted]),
ALLEXCEPT(SalesTable, SalesTable[Product])
)
Didn't think about that. Can you not just convert the month to date with DAX in a new column like:
Hi Jamie, I want to ask you one more question. If I expand my table with product name like this:
and I used your DAX, when I use matrix visual to breakdown amount of product sold, the value of previous month did not show amount of each product, instead the total amount of previous month of all products
Could you help me resolve this problem.
Kind regards,
Hi there,
I think it's because of the REMOVEFILTERS() piece. Could you try changing the measure to use the ALLEXCEPT function;
CALCULATE(
SUM(SalesTable[SALES]),
PREVIOUSMONTH(SalesTable[MonthToDateConverted]),
ALLEXCEPT(SalesTable, SalesTable[Product])
)
Thanks a lot. It works like charm
Thank you so much, it works now 😄
If you don't want to convert to date format... It looks like you're using a numerical value, which should always increase in value, so you can just take the max -1 from that value.
Sales PrevMo =
VAR PrevMonth = MAX('Table'[Month]) - 1
RETURN
CALCULATE(SUM('Table'[Sales]), 'Table'[Month] = PrevMonth)
Nice idea, I tried your solution earlier, but the problem when year change, the calculation skip it. The result is like this 😄
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
118 | |
75 | |
47 | |
45 | |
32 |
User | Count |
---|---|
172 | |
90 | |
66 | |
46 | |
45 |