Forum Discussion
YTD Cumulative Numbers by week
Experts,
I have four year worth of data in my source table. They are transactions by date. I am trying to retrieve YTD numbers by week. I used following formula. Without any filters, Power BI is retrieving current year or 2020 numbers. When I do the same for 2019, with or without filter ( 2019), it is showing blank. I do have a calendar table set up. I have the canvas, source data table, and calendar table attached. Please kindly advise. I think that my source data might need to be massaged.
- Anonymous6 years ago
Hi Anonymous,
Time intelligence function does not agility enough to work with all scenarios. (it also not support to do customize internal calculations or nested with multiple time intelligence functions)
BTW, it also requires completed table records and a common structure date calendar to do rolling calculations.For your scenario, I'd like to suggest you try to manually use year and weeknum function to manually defined the filter range for calculation, it should dynamic interaction with filters.
Measure = VAR currDate = MAX ( Table[Date] ) RETURN CALCULATE ( SUM ( Table[amount] ), FILTER ( ALLSELECTED ( Table ), YEAR ( Table[Date] ) = YEAR ( currDate ) && WEEKNUM ( Table[Date], 1 ) <= WEEKNUM ( currDate, 1 ) ) )Reference link:
Time Intelligence "The Hard Way" (TITHW)
Regards,Xiaoxin Sheng
4 Replies
- amitchandakSuper User
Anonymous , When plot YTD number by Day, you can see it increase by Day. If you plot by month, you will see an increase by month.
So my assumption is if you have a week in Date calendar and you plot WEEK and you should see YTD by WEEK
refer:https://www.dropbox.com/s/a9xq913pgvuzg2x/sales_analytics_weekWiseMon_sun.pbix?dl=0
https://www.dropbox.com/s/d9898a48e76wmvl/sales_analytics_weekWise.pbix?dl=0
- AnonymousNot applicable
Yes,
But then, why it's showing only current year info. I have the numbers in the source data from 2017. It's only showing 2020.
And if put a filter for 2019 on, it's showing blank.
Jen
- amitchandakSuper User
Anonymous , Formula is fine. Unless there is some other filter or the date join have some issue like joined to some other date. Or date has a timestamp.
- AnonymousNot applicable
Hi Anonymous,
Time intelligence function does not agility enough to work with all scenarios. (it also not support to do customize internal calculations or nested with multiple time intelligence functions)
BTW, it also requires completed table records and a common structure date calendar to do rolling calculations.For your scenario, I'd like to suggest you try to manually use year and weeknum function to manually defined the filter range for calculation, it should dynamic interaction with filters.
Measure = VAR currDate = MAX ( Table[Date] ) RETURN CALCULATE ( SUM ( Table[amount] ), FILTER ( ALLSELECTED ( Table ), YEAR ( Table[Date] ) = YEAR ( currDate ) && WEEKNUM ( Table[Date], 1 ) <= WEEKNUM ( currDate, 1 ) ) )Reference link:
Time Intelligence "The Hard Way" (TITHW)
Regards,Xiaoxin Sheng