Forum Discussion
Running total not giving correct answer
I'm trying to get the running sum of hours of a measure that ultimately includes a calculation of an average.
Power BI isn't giving me the correct answer.
| Correct Hours | Power BIs answer | ||
| 4. Available Hours | 5. Running Sum | ||
| 2024/Dec | 730.86 | 730.86 | 730.86 |
| 2025/Jan | 766.72 | 1497.58 | 1497.59 |
| 2025/Feb | 689.6 | 2187.18 | 2186.64 |
| 2025/Mar | 731.61 | 2918.79 | 2918.79 |
| 2025/Apr | 938.94 | 3857.73 | 3850.01 |
| 2025/May | 773.66 | 4631.39 | 4623.77 |
| 2025/Jun | 710.72 | 5342.11 | 5333.61 |
| 2025/Jul | 671.75 | 6013.86 | 6000.06 |
| 2025/Aug | 562.42 | 6576.28 | 6562.02 |
| 2025/Sep | 685.42 | 7261.7 | 7247.52 |
| 2025/Oct | 845.69 | 8107.39 | 8086.51 |
| 2025/Nov | 539.07 | 8646.46 | 8638.06 |
| 2025/Dec | 778.5 | 9424.96 | 9413.33 |
| 2026/Jan | 532.49 | 9957.45 | 9948.18 |
| 2026/Feb | 531.27 | 10488.72 | 10483.54 |
| 2026/Mar | 643.04 | 11131.76 | 11123.57 |
| 2026/Apr | 0 | 11131.76 | 10799.53 |
| 2026/May | 0 | 11131.76 | 10313.08 |
There are a string of formulas used to make 5. Running sum
hello Devon-Yeager
if i am not misunderstood the discussion, the problem is how to calculate running sum from a measure.
next the [Available Hours] is a form of measure from another calculation.
please check if this accomodate your expected result (please ignore the index as it works only as sorting in table visual).
i think the [5. Running Sum] above should be matched to your correct hours.
create a new measure for calculating Running Sum
5. Running Sum =
SUMX(
FILTER(
ALL('Table'),
'Table'[Date]<=MAX('Table'[Date])
),
[Available Hours]
)i made the [Available Hours] above as a measure because your original data has [Available Hours] as measure.i assumed you have expected result for calculations before [Available Hours].Hope this will help.Thank you.
14 Replies
- Devon-YeagerFrequent Visitor
Here are a couple more columns of data to help tell the story
Correct Hours Power BIs answer What If Employee Count 3. Total Available Hours 4. Available Hours 5. Running Sum 2024/Dec 9.18 1006.86 730.86 730.86 730.86 2025/Jan 9.18 1048.72 766.72 1497.58 1497.59 2025/Feb 9.18 998.6 689.6 2187.18 2186.64 2025/Mar 9.18 1036.61 731.61 2918.79 2918.79 2025/Apr 10.18 1217.94 938.94 3857.73 3850.01 2025/May 9.18 1042.66 773.66 4631.39 4623.77 2025/Jun 9.18 945.72 710.72 5342.11 5333.61 2025/Jul 10.18 1139.75 671.75 6013.86 6000.06 2025/Aug 10.18 1030.42 562.42 6576.28 6562.02 2025/Sep 10.18 1132.42 685.42 7261.7 7247.52 2025/Oct 10.18 1260.69 845.69 8107.39 8086.51 2025/Nov 10.18 954.07 539.07 8646.46 8638.06 2025/Dec 10.18 1193.5 778.5 9424.96 9413.33 2026/Jan 10.18 1113.49 532.49 9957.45 9948.18 2026/Feb 10.18 1112.27 531.27 10488.72 10483.54 2026/Mar 10.18 1224.04 643.04 11131.76 11123.57 2026/Apr 10.18 1217.94 0 11131.76 10799.53 2026/May 10.18 1107.38 0 11131.76 10313.08 - Ashish_MathurSuper User
Hi,
This pattern should work
- Create a Calendar Table with calculated column formulas of Year, Month name and Month number
- Sort the Month name column by the Month number
- Create a relationship (Many to One and single) from the Date column of your fact table to the Date column of the Calendar Table
- Write this measure
Measure = calculate([4. Available hours],datesbetween(calendar[date],minx(all(calendar),calendar[date]),max(calendar[date])))
Hope this helps.
- Devon-YeagerFrequent Visitor
Thank you Ashish for providing this solution. It's still not providing the correct results though. There are many months in the data before the current month. I need the measure to only consider this month and forward.
I also tried adding a condition to the measure: 'Date Table'[* Before end of last month] = "No", this provided the same results as the original measure I created.
Here are the new results using your measure:
Year Month 4. Available Hours 5. Running sum Measure 2024/Dec 730.86 730.86 153765.46 2025/Jan 766.72 1497.59 154532.19 2025/Feb 689.6 2186.64 155221.79 2025/Mar 731.61 2918.79 155953.39 2025/Apr 938.94 3850.01 160290.6 2025/May 773.66 4623.77 160497.06 2025/Jun 710.72 5333.61 160801.39 2025/Jul 671.75 6000.06 163291.95 2025/Aug 562.42 6562.02 165273.29 2025/Sep 685.42 7247.52 167093.78 2025/Oct 845.69 8086.51 168861.09 2025/Nov 539.07 8638.06 170187.08 2025/Dec 778.5 9413.33 171617.13 2026/Jan 532.49 9948.18 172713.49 2026/Feb 531.27 10483.54 173735.65 2026/Mar 643.04 11123.57 174801.06 2026/Apr 0 10799.53 174852.79 2026/May 0 10313.08 174700.17 - Ashish_MathurSuper User
Follow the instructions mentioned in my previuos mail and revise the measure to
Measure = calculate([4. Available hours],datesbetween(calendar[date],eomonth(today(),-1)+1,max(calendar[date])))
Hope this helps.
- AnonymousNot applicable
Hi Devon-Yeager ,
Please provide sample PBIX files so we can better understand and help you.
Refer to the following link on how to upload a PBIX file.How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.
Best Regards,
Dengliang Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- Devon-YeagerFrequent Visitor
Thank you for the instructions. Another person provided a solution so I don't need to upload the pbix. I will keep this in mind for other needs.