Forum Discussion
Creating Trend comparing current week with previous week
Hi Team,
Required assistance, I am trying to create weekly trend comparing current wk vs previous week, used below dax but not getting correct result
Colum:
Measure, highlighted in red is also measure
Below is screen print where Trend suppose to get 18th data but getting incorrect result
25th Data
Once i get correct result for Trend i can create new Measure as per below comparison.
Regards,
Hari
harirao I'm assuming you have a DimDate table??
If not, get one, they make a big difference:
https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html
Once you have the date table, I would consider a slightly different approach to this problem, using time intelligence to change the filter context within the measure, rather than creating a calculated column for previous period.
So something like:
Trend =CALCULATE([%6week_1&2], DATEADD(DimDate[Date], -7, DAY))No need to mess with region as that will come automatically from the context of the matrix.harirao A small update:In the slicer, either use the:DimDate[Date] ,DimDate[ReportWeek]DimDate[Week]Basically anything from the DimDate table NOT the Query1[reportdate]harirao , refer to my blog on how to work with the week; this week vs last week etc.
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.
2 Replies
- AllisonKennedyCommunity Champion
harirao I'm assuming you have a DimDate table??
If not, get one, they make a big difference:
https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html
Once you have the date table, I would consider a slightly different approach to this problem, using time intelligence to change the filter context within the measure, rather than creating a calculated column for previous period.
So something like:
Trend =CALCULATE([%6week_1&2], DATEADD(DimDate[Date], -7, DAY))No need to mess with region as that will come automatically from the context of the matrix.harirao A small update:In the slicer, either use the:DimDate[Date] ,DimDate[ReportWeek]DimDate[Week]Basically anything from the DimDate table NOT the Query1[reportdate] - amitchandakSuper User
harirao , refer to my blog on how to work with the week; this week vs last week etc.
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.