Forum Discussion
Grouping YTD by weeks not having intended effect
- 7 years ago
OK, this may not be what you want but maybe it gets you closer. I took your first table and I created this column:
WeekNum = WEEKNUM([YTDcol2])
Then I created these two measures:
AccumShift_Dur_Hrs running total in WeekNum = CALCULATE( SUM('Table12'[AccumShift_Dur_Hrs]), FILTER( ALLSELECTED('Table12'[WeekNum]), ISONORAFTER('Table12'[WeekNum], MAX('Table12'[WeekNum]), DESC) ) ) YTDdelayHrs running total in WeekNum = CALCULATE( SUM('Table12'[YTDdelayHrs]), FILTER( ALLSELECTED('Table12'[WeekNum]), ISONORAFTER('Table12'[WeekNum], MAX('Table12'[WeekNum]), DESC) ) )I could then put my WeekNum column and these two measures in a table visualization and get a running total for each. Is that what you are going for?
Can you post your sample source data so that it can be copied and pasted? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
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
| YTDcol2 | AccumShift_Dur_Hrs | YTDdelayHrs |
| 1/1/16 12:00 AM | 24 | 1.35 |
| 1/2/16 12:00 AM | 48 | 6.22 |
| 1/3/16 12:00 AM | 72 | 7.66 |
| 1/4/16 12:00 AM | 96 | 11.21 |
| 1/5/16 12:00 AM | 120 | 14.32 |
| 1/6/16 12:00 AM | 144 | 38.21 |
| 1/7/16 12:00 AM | 168 | 38.93 |
| 1/8/16 12:00 AM | 198 | 41.25 |
| 1/9/16 12:00 AM | 216 | 42.12 |
| 1/10/16 12:00 AM | 240 | 42.51 |
| 1/11/16 12:00 AM | 264 | 43.66 |
| 1/12/16 12:00 AM | 288 | 44.21 |
| 1/13/16 12:00 AM | 312 | 45.76 |
| 1/14/16 12:00 AM | 336 | 51.56 |
| WeekYear | YTDmeasure2 | YTDdelayhrsUnplanned |
| 2018-1 | 96 | 9.52 |
| 2018-2 | 168 | 22.13 |
| 2018-3 | 168 | 18.71 |
| 2018-4 | 168 | 21.23 |
| 2018-5 | 168 | 44.25 |
| 2018-6 | 168 | 16.42 |
| WeekYear | YTDmeasure2 | YTDdelayhrsUnplanned |
| 2018-1 | 96 | 9.52 |
| 2018-2 | 264 | 31.65 |
| 2018-3 | 432 | 50.36 |
| 2018-4 | 600 | 71.59 |
| 2018-5 | 768 | 115.84 |
| 2018-6 | 936 | 132.26 |
Note that the data is just for an example to understand the problem.
Thanks Greg. ~Lucas
- Greg_Deckler7 years ago
Community Champion
OK, this may not be what you want but maybe it gets you closer. I took your first table and I created this column:
WeekNum = WEEKNUM([YTDcol2])
Then I created these two measures:
AccumShift_Dur_Hrs running total in WeekNum = CALCULATE( SUM('Table12'[AccumShift_Dur_Hrs]), FILTER( ALLSELECTED('Table12'[WeekNum]), ISONORAFTER('Table12'[WeekNum], MAX('Table12'[WeekNum]), DESC) ) ) YTDdelayHrs running total in WeekNum = CALCULATE( SUM('Table12'[YTDdelayHrs]), FILTER( ALLSELECTED('Table12'[WeekNum]), ISONORAFTER('Table12'[WeekNum], MAX('Table12'[WeekNum]), DESC) ) )I could then put my WeekNum column and these two measures in a table visualization and get a running total for each. Is that what you are going for?
- test_123_e2137 years agoFrequent Visitor
Wow this works great!
Thanks!
Would you know if there's a way to have this work with my WeekYear label?
It's nice to display 2018-1, 2018-2 on the graph.
The goal, but with accumulating dataWhat I currently have
I've just been trying and can't get it to work.
Thanks for your help. No worries if I can't get this second part to work.
- Greg_Deckler7 years ago
Community Champion
Well, if you WeekYear is in the same table as the original data then you should just use that in your table visualization rather than the WeekNum. Should work identically as the measure should have the correct context to calculate correctly. Or is your WeekYear in a different table? I am thinking it is a table like:
Date,WeekNum,WeekYear,Column1,Column2,Column3