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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

previous month

Hi all,

 

i want to calucaluate the previous month count   using  below exp not working fine

 

my Date field is  Calendar_date   and    values are    01-Apr-20    like that   

 

this is my DB view ,.  Vw_fact_AIS_9R_SPECIFIC_SHIPMENT_REPORT

 

Prev Month count = CALCULATE([SKU_Count],dateadd(dates(Vw_fact_AIS_9R_SPECIFIC_SHIPMENT_REPORT.Calendar_date),-1,MONTH))
2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hello,

 

I am pretty sure that it only works with a dimension date table, so using this table your expression would be like the following:

 

Prev Month count = CALCULATE([SKU_Count],dateadd(dim_date[.Calendar_date],-1,MONTH))

 

View solution in original post

@Anonymous , not sure the name of date in date table, one of the following

CALCULATE([SKU_Count],dateadd(dim_date[Calendar_date],-1,MONTH))

CALCULATE([SKU_Count],dateadd(dim_date[Date],-1,MONTH))

CALCULATE([SKU_Count],DATESMTD(dateadd(dim_date[Date],-1,MONTH)))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@Anonymous , Use Date calendar

Prev Month count = CALCULATE([SKU_Count],dateadd(Date[Date],-1,MONTH))
MTD Sales = CALCULATE([SKU_Count],DATESMTD('Date'[Date]))
Last month= CALCULATE([SKU_Count],previousmonth('Date'[Date]))
last MTD Sales = CALCULATE([SKU_Count],DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales =  CALCULATE([SKU_Count],DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

m getting below error.

 

cl date.PNG

Anonymous
Not applicable

Hello,

 

I am pretty sure that it only works with a dimension date table, so using this table your expression would be like the following:

 

Prev Month count = CALCULATE([SKU_Count],dateadd(dim_date[.Calendar_date],-1,MONTH))

 
Anonymous
Not applicable

thnk you . i dont have  dim table  i have only  one main table 

 

how to modify the exp?

 

CALCULATE([SKU_Count],dateadd(dim_date[.Calendar_date],-1,MONTH))

@Anonymous , not sure the name of date in date table, one of the following

CALCULATE([SKU_Count],dateadd(dim_date[Calendar_date],-1,MONTH))

CALCULATE([SKU_Count],dateadd(dim_date[Date],-1,MONTH))

CALCULATE([SKU_Count],DATESMTD(dateadd(dim_date[Date],-1,MONTH)))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi

i dont have date table ..  

 

i have only main table. 

@Anonymous - See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.