cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tahir9 Frequent Visitor
Frequent Visitor

Getting prior month data to display for current month?

Hello i am trying to display the prior month totals as a measure in a table where i am showing the totals by month and year... but my measure formula isn't working not sure why? Here is the formula:

 

Prior days = CALCULATE(SUM('Calendar'[Work Day]),PARALLELPERIOD('Calendar'[Date].[Date],-1,MONTH))

 

As you can see in the table below i want the 24 for january to show up in february and so on... but the formula above only returns that months totals... 

 

image.png

1 ACCEPTED SOLUTION

Accepted Solutions
Phil_Seamark Super Contributor
Super Contributor

Re: Getting prior month data to display for current month?

HI @tahir9

 

Please try this calculated measure

 

Prior days = 
    CALCULATE(
        SUM('Calendar'[Work Day]),
        ALL('Calendar'),
        PREVIOUSMONTH('Calendar'[Date])
        )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

4 REPLIES 4
Phil_Seamark Super Contributor
Super Contributor

Re: Getting prior month data to display for current month?

HI @tahir9

 

Please try this calculated measure

 

Prior days = 
    CALCULATE(
        SUM('Calendar'[Work Day]),
        ALL('Calendar'),
        PREVIOUSMONTH('Calendar'[Date])
        )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

tahir9 Frequent Visitor
Frequent Visitor

Re: Getting prior month data to display for current month?

that worked Phil! Thank you! Just curious if you could explain why that worked but my method did not... ?

Phil_Seamark Super Contributor
Super Contributor

Re: Getting prior month data to display for current month?

HI @tahir9

 

The magic function in my calculation is the ALL function.  This allows me to remove the implicit filtering being applied to the underlying dataset and have access to different rows.  If you do some internet searching for DAX Filter Context, there will be a bunch of articles or blogs that describe it.  I have a section in my book (aka.ms/practicalDAX) that you may also find useful.

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

tahir9 Frequent Visitor
Frequent Visitor

Re: Getting prior month data to display for current month?

Thanks Phil will check out your book as well as these other resources! 

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 160 members 1,769 guests
Please welcome our newest community members: