Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello, I'm struggling with a cumulative sum issue. I'm simplifiying the scenario here, however I have a table with date, accounting document reference, reason of accounting movement and amount. I want to create a measure which calculates the cumulative sum of the amount for each row, without grouping the movements that share the same date.
The following pictures shows what I want. Look how despite 3 rows share the same date, the cumulative sum is calculated for each row.
I've tried several filter functions, without reaching the result. The following measure doesn't make the job, since the cumulative sum is grouped for the 3 rows sharing the date.
Any help, please?
Solved! Go to Solution.
Thanks for the reply from @some_bih , please allow me to provide another insight:
Hi @DataAnalystEvo ,
In your data you have the same date, so in the calculation it will add all the values for the same date 2022.4.30 as one, you can consider creating an Index that assigns a separate label to each row.
There are two ways to create an Index, one on Power Query and the other way you can follow the steps below
In Power Query -- add Column – Index Column – From 1.
Here are the steps you can follow:
1. Create calculated column.
Index =
var _search=SEARCH(".",'Table'[Document],1)
return
VALUE(RIGHT(
[Document],
LEN([Document]) - _search))
2. Create measure.
Measure =
SUMX(
FILTER(ALL('Table'),
'Table'[Index]<=MAX('Table'[Index])),[Amount])
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thanks for the reply from @some_bih , please allow me to provide another insight:
Hi @DataAnalystEvo ,
In your data you have the same date, so in the calculation it will add all the values for the same date 2022.4.30 as one, you can consider creating an Index that assigns a separate label to each row.
There are two ways to create an Index, one on Power Query and the other way you can follow the steps below
In Power Query -- add Column – Index Column – From 1.
Here are the steps you can follow:
1. Create calculated column.
Index =
var _search=SEARCH(".",'Table'[Document],1)
return
VALUE(RIGHT(
[Document],
LEN([Document]) - _search))
2. Create measure.
Measure =
SUMX(
FILTER(ALL('Table'),
'Table'[Index]<=MAX('Table'[Index])),[Amount])
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thank you @v-yangliu-msft .
As I said, I was oversimplifiyng the scenario in my post. I have a huge fact table with a very complex data model, and more filters are included in the measure I have to build. Indeed, I had already tried with a Power Query-calculated index column, but it didn't work, the measure was extremely slow and thus ineffective. However, I found that your advice is effective. For some reason still not so clear to me, SUMX + FILTER(Table) is way more quick and I achieved my goal. Thank you.
Hi @DataAnalystEvo try v2 below
Proud to be a Super User!
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
25 | |
19 | |
18 | |
18 | |
15 |
User | Count |
---|---|
39 | |
22 | |
18 | |
15 | |
12 |