Forum Discussion
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
- Anonymous6 years ago
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 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)))
7 Replies
- AnonymousNot 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))
- AnonymousNot 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))
- amitchandakSuper User
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)))
- amitchandakSuper 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.- AnonymousNot applicable
m getting below error.