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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Calculate PreviousMonth doesnt work

Hi Guys,

 

I tried to calculate the total purchase id from table PurchTable from the previous month.

My current measure is:

 

Previous Month Purchase ID = CALCULATE(COUNT(PURCHTABLE[PURCHID]), PREVIOUSMONTH('DATE'[Date])) 

 

Unfortunatly it doesnt show the result...

 

2017-11-28 16_13_40-Analysis Case backlog 2984 - Power BI Desktop.png

 

This is the relationship between Date table and PurchTable.

 

2017-11-28 16_14_28-Analysis Case backlog 2984 - Power BI Desktop.png

 

 

Any suggestion?

 

Thanks in advances.

 

Rega Sanyoto

1 ACCEPTED SOLUTION

In order to show the count of previous month's purchaseIDs on each row, you have to remove the relevant filter context using ALL:

 

Previous Month Purchase ID

= CALCULATE(

          COUNT(PURCHTABLE[PURCHID])

         , PREVIOUSMONTH('DATE'[Date])

         , ALL(PURCHTABLE[PURCHID])

          ) 

 

View solution in original post

3 REPLIES 3
KHorseman
Community Champion
Community Champion

Does that table visual have any date context? I don't see anything obvious but maybe you've just used a filter. PREVIOUSMONTH returns the month prior to the first date in the given date context. It's not just automatically the month before today.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

hI @KHorseman,

 

Thanks , i didnt filter any date in a slicer. I just set a date in a slicer and now it give a total amount of the count of all purchId. which is 47.

 

But it didnt show me how much the purchid from the previous month on each row. Look at the image below. Any suggestions how i can show the numbers on each rows ?

 

2017-11-29 09_26_40-Analysis Case backlog 2984 - Power BI Desktop.png

In order to show the count of previous month's purchaseIDs on each row, you have to remove the relevant filter context using ALL:

 

Previous Month Purchase ID

= CALCULATE(

          COUNT(PURCHTABLE[PURCHID])

         , PREVIOUSMONTH('DATE'[Date])

         , ALL(PURCHTABLE[PURCHID])

          ) 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors