Forum Discussion
Running total kg per week
Hi,
I have a table that looks like this:
| ID | Site | Week | Date | Total kg | Total kg site | Total kg week |
| 260 | A | 4 | 26/01/2024 | 978,0 | 23 061 | 19 045 |
| 259 | A | 4 | 26/01/2024 | 980,0 | 22 083 | 18 067 |
| 258 | A | 4 | 26/01/2024 | 1 019,0 | 21 103 | 17 087 |
| 257 | A | 4 | 25/01/2024 | 858,6 | 20 084 | 16 068 |
| 256 | A | 4 | 25/01/2024 | 1 035,0 | 19 225 | 15 209 |
| 255 | A | 4 | 25/01/2024 | 2 057,0 | 18 190 | 14 174 |
| 254 | A | 4 | 24/01/2024 | 1 040,0 | 16 133 | 12 117 |
| 253 | A | 4 | 24/01/2024 | 1 055,0 | 15 093 | 11 077 |
| 252 | A | 4 | 24/01/2024 | 2 053,0 | 14 038 | 10 022 |
| 251 | A | 4 | 23/01/2024 | 1 020,0 | 11 985 | 7 969 |
| 250 | A | 4 | 23/01/2024 | 1 032,0 | 10 965 | 6 949 |
| 249 | A | 4 | 23/01/2024 | 1 750,0 | 9 933 | 5 917 |
| 248 | A | 4 | 22/01/2024 | 1 035,0 | 8 183 | 4 167 |
| 247 | A | 4 | 22/01/2024 | 3 132,0 | 7 148 | |
| 246 | A | 3 | 21/01/2024 | 1 928,0 | 4 016 | |
| 245 | A | 3 | 20/01/2024 | 2 088,0 | 2 088 |
I would like the column Total kg week to calculate how much the toal kg:s are per week as the week goes by, as in the example is calculated for week 4. And for the Total kg site to calculate total kg:s for the site as time goes by. Of course there will be other sites too in the table. Is this possible to do in Power BI?
Grateful for answers.
5 Replies
- AnonymousNot applicable
HI sw123,
What version of weekly total are you wanted? The dynamic rolling 7 days or aggregated records based on current week number?
Here are sample measure formulas of rolling 7 days and weekly total based on current site group:
Rolling 7day = VAR currDate = MAX ( Table1[Date] ) RETURN CALCULATE ( SUM ( Table1[Total kg] ), FILTER ( ALLSELECTED ( Table1 ), [Date] >= currDate - 7 ), VALUES ( Table1[Site] ) ) Total per week = VAR currDate = MAX ( Table1[Date] ) RETURN CALCULATE ( SUM ( Table1[Total kg] ), FILTER ( ALLSELECTED ( Table1 ), YEAR ( [Date] ) = YEAR ( currDate ) && WEEKNUM ( [Date] ) = WEEKNUM ( currDate ) ), VALUES ( Table1[Site] ) )Regards,
Xiaoxin Sheng
- sw123
Helper III
Hi, I want to have it based on the week number, like running totals for week 1, new running totals for week 2 and so on.
Thank you for the formulas. I will try these.
- sw123
Helper III
Hi,
I tried the Total per week formula, but it gave me the same value as in column Total kg?
Can you tell me what is wrong?
- AnonymousNot applicable
Hi sw123 ,
Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly
Notice: please not attach any sensitive data in sample.
Regards,
Xiaoxin Sheng