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 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)))

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.

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)))

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


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.