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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
naoyixue1
Post Patron
Post Patron

Last Month Calculation based on not fiscal Month

Hey there,

 

Try to calculate the previous month production. Although I already add one column for 'YearandMonth' (year*100+month) in whole number format, but it still doesn't work. I think my logic is correct, but it always shows zero...just no idea what's wrong with that dax? Would you help to check? Thanks!

 

naoyixue1_0-1621182168355.png

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @naoyixue1 

Try this,

Last Month Production=Calculate([Produced Qty],Filter(ALL('Time Lookup'),'Time Lookup'[YearandMonth]=Selectedvalue('Time Lookup'[YearandMonth])-1))

If the problem is still not solved, it indicates that your formula seems to be OK, so maybe there's something wrong with your measure.

Can you provide more details about your data model and table structure, or PBI sample file after removing sensitive information? It will help to work out the solution quickly.

 

Best Regards,

Community Support Team _ Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @naoyixue1 

Try this,

Last Month Production=Calculate([Produced Qty],Filter(ALL('Time Lookup'),'Time Lookup'[YearandMonth]=Selectedvalue('Time Lookup'[YearandMonth])-1))

If the problem is still not solved, it indicates that your formula seems to be OK, so maybe there's something wrong with your measure.

Can you provide more details about your data model and table structure, or PBI sample file after removing sensitive information? It will help to work out the solution quickly.

 

Best Regards,

Community Support Team _ Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

@v-xiaotang It works. Thanks a lot! 

 

Yi

Ashish_Mathur
Super User
Super User

Hi,

If you have a Calendar set up with a proper relationship to your base data table and your slicer is from the Calendar table, then this simple measure should work

=calculate([product qty],previousmonth(calendar[date]))

Ensure that you select a Year/Month in the slicer.

Hope this helps.


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

Hey Ashish Mathur,

 

Thanks. But I'm now dealing with the non standard calendar...That's why I cannot use that previousmonth dax to calculate. Thanks!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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