Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
gsandip
Frequent Visitor

PREVIOUSMONTH() function does not working for me

Hi,

I have written PREVIOUSMONTH() in below measure:

Previous Month Sales =
VAR vSales = CALCULATE(
sum(Orders[Sales]), PREVIOUSMONTH('Calendar'[Date])
)
RETURN
IF(vSales = blank(), 0, vSales)
 
But, it is not working properly like below:
gsandip_0-1679049445369.png

which you can see is incorrent, but when I add Year from my calendar, then year wise and monthwise it is showing correct result like below:

gsandip_1-1679049623509.png

So, why it is hapenning here? actually I don't want to use Year column in my table and want the correct result, but it is showing wrong when I remove Year column from table.


 

 

1 ACCEPTED SOLUTION

Hi,

I got the solution here By @amitchandak 

(1) Power BI Offset Compare Categories, Time Intelligence MOM, QOQ, YOY - YouTube

I have used below DAX and it works fine for me.

Previous Month Sales = CALCULATE (     SUM ( Orders [Sales] ), OFFSET (- 1 , ALLSELECTED ( 'Orders' [Month Name] , Orders [Month Num] ), ORDERBY ( 'Orders' [Month Num] , ASC ), KEEP ) )  

 

Great Help

Thank you,

Sandip Ghosh

View solution in original post

3 REPLIES 3
Ahmedx
Super User
Super User

in that case you need new features OFFSET

Hi,

I don't understand it, can you please give me the syntax or modified DAX what I was using?

Hi,

I got the solution here By @amitchandak 

(1) Power BI Offset Compare Categories, Time Intelligence MOM, QOQ, YOY - YouTube

I have used below DAX and it works fine for me.

Previous Month Sales = CALCULATE (     SUM ( Orders [Sales] ), OFFSET (- 1 , ALLSELECTED ( 'Orders' [Month Name] , Orders [Month Num] ), ORDERBY ( 'Orders' [Month Num] , ASC ), KEEP ) )  

 

Great Help

Thank you,

Sandip Ghosh

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.