Forum Discussion
Getting a sum of a specific colum
See if the attached is getting you closer to what you need.
Dear lbendlin ,
thanks for your help - i really appreciate it.
ROW 1080 is correct in this case. But the problem ist that the rows need to be calculated differently.
f.ex.
1080 = 1051 - 1060
1092 = 1080 + sum of bwa zeile >= 1080 and bwa zeiule <= 1090
Here are the different calculation formulas for the rows:
#"S1051" = Table.AddColumn(#"Gefilterte Zeilen1", "1051", each if (([BWA Zeile] >= 1020) and ([BWA Zeile] <= 1045)) then[Umsatz Values] else 0),
S1080 = Table.AddColumn(S1051, "1080", each [1051] - (if [BWA Zeile] = 1060 then [Umsatz Values] else 0)),
#"S1092" = Table.AddColumn(S1080, "1092", each [1080] + (if ([BWA Zeile] >= 1080) and ([BWA Zeile] <= 1090) then [Umsatz Values] else 0)),
#"S1280" = Table.AddColumn(#"S1092", "1280", each if (([BWA Zeile] >= 1100) and ([BWA Zeile] <= 1260)) then [Umsatz Values] else 0),
#"S1300" = Table.AddColumn(#"S1280", "1300", each [1092] - [1280]),
#"S1320" = Table.AddColumn(#"S1300", "1320", each if (([BWA Zeile] >= 1310) and ([BWA Zeile] <= 1312)) then [Umsatz Values] else 0),
#"S1330" = Table.AddColumn(#"S1320", "1330", each if (([BWA Zeile] >= 1320) and ([BWA Zeile] <= 1324)) then[Umsatz Values] else 0),
#"S1345" = Table.AddColumn(#"S1330", "1345", each [1300] - [1320] + [1330]),
#"S1380" = Table.AddColumn(#"S1345", "1380", each [1345] - (if ([BWA Zeile] = 1355) then[Umsatz Values] else 0)),
Do you have any idea?
- lbendlin4 years ago
Super User
My previous post was showing an implementation as a measure. You seem to prefer an implementation as a calculated column or directly in Power Query? Do you want to create additional columns for each rule, or do you want to replace existing values in the same column?
- SvenJ4 years ago
Helper III
Do you want to create additional columns for each rule
Yes, as it is not 100% clear, how the structure is at the end. I would prefer the easiest way. What's the most "safe" way?
- lbendlin4 years ago
Super User
From a data preparation perspective the safest way is not to destroy any information - this means creating new columns for each of the rules.
From a data visualization perspective that is the worst possible outcome.
- SvenJ4 years ago
Helper III
What's your suggestion? ... and maybe solution?
- lbendlin4 years ago
Super User
I would keep the source data as is and would implement the logic in DAX, similar to what I have shown for the 1080 case.
- SvenJ4 years ago
Helper III
Can you give me an example how to add a second rule? Maybe i can get it down by myself if i have an example.