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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Previous Months Field

Found this thread 

https://community.powerbi.com/t5/Desktop/PREVIOUSMONTH/td-p/13307

 

tested both these as columns, both worked with correct value
WIP PARTS SUM = CALCULATE(SUM('WebtrimCentral_MTD'[WIP PARTS])) = correct value
Previous Month Date = DATEADD ('WebtrimCentral_MTD'[CreateDate], -1, MONTH) = correct value

 

Tried to combine to this and it just returns blank?

 

Prev Month WIP PARTS =
CALCULATE (
SUM('WebtrimCentral_MTD'[WIP PARTS]),
DATEADD ( 'WebtrimCentral_MTD'[CreateDate], -1, MONTH )
)

 

anybody know more 😞

1 ACCEPTED SOLUTION

@Anonymous 

You should have both.  Having the base [WIP PARTS SUM] measure lets you use it other measure like last month, last year, margin rates, etc.  Since you have a date table you should use that as your adjustment for the date calc.

Prev Month WIP PARTS =
CALCULATE (
    [WIP PARTS SUM],
    DATEADD ('DateDimension'[Date], -1, MONTH )
)

Make sure your DateDimension table is marked as the date table.

DateTable.jpg

And turn off the cross filtereing on the relationship.  It should just flow from the DateDimension table to the WebtrimCentral_MTD

DateRelationship.jpg

And you just make sure to pull any field related to date from your DateDimension table.

Take a look at this training course, they cover a lot of these concepts and it's free.  https://www.sqlbi.com/p/introducing-dax-video-course/

 

View solution in original post

4 REPLIES 4
jdbuchanan71
Super User
Super User

Hello @Anonymous 

Two small changes to your measures.  Your first sum does not need the calculate so go with this.

WIP PARTS SUM = SUM ( 'WebtrimCentral_MTD'[WIP PARTS] )

Your Prev Month amount measure can just use the regular sum measure like so.

Prev Month WIP PARTS =
CALCULATE (
    [WIP PARTS SUM],
    DATEADD ( 'WebtrimCentral_MTD'[CreateDate], -1, MONTH )
)

 

Anonymous
Not applicable

@jdbuchanan71 Thanks that worked. Do i need to use two measures, should I not just combine into one?

 

Got a new problem now. It works but if I choose to filter based on another field (related) it's showing as blank

 

 

pbi-1.pngpbi-2.pngpbi-3.png

Hi,

You may also try this measure

Prev Month WIP PARTS =CALCULATE([WIP PARTS SUM],PREVIOUSMONTH('DateDimension'[Date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Anonymous 

You should have both.  Having the base [WIP PARTS SUM] measure lets you use it other measure like last month, last year, margin rates, etc.  Since you have a date table you should use that as your adjustment for the date calc.

Prev Month WIP PARTS =
CALCULATE (
    [WIP PARTS SUM],
    DATEADD ('DateDimension'[Date], -1, MONTH )
)

Make sure your DateDimension table is marked as the date table.

DateTable.jpg

And turn off the cross filtereing on the relationship.  It should just flow from the DateDimension table to the WebtrimCentral_MTD

DateRelationship.jpg

And you just make sure to pull any field related to date from your DateDimension table.

Take a look at this training course, they cover a lot of these concepts and it's free.  https://www.sqlbi.com/p/introducing-dax-video-course/

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.