Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi, I am new to power BI , having the following scenario
INPUT
INPUT |
10-1,1-1 |
1-1,3-1,2-1 |
1-1,3-1,2-1,13-2 |
1-1,2-2,3-1 |
5-2,10-1,1-1,6-1,3-1,9-2 |
OUTPUT should be
OUTPUT | SUM |
10-1,1-1 | 2 |
1-1,3-1,2-1 | 3 |
1-1,3-1,2-1,13-2 | 5 |
1-1,2-2,3-1 | 4 |
5-2,10-1,1-1,6-1,3-1,9-2 | 8 |
I need to achieve this result by DAX
steps:
1. first i need to get the value after (-)
2. then sum of that val
The data isn't really in a format that's going to allow you to do this. It'll need some transformation in Power Query first.
You have the list of inputs, but you'll need to add a index to use as a key. Then, you'll need a table that lists out all the elements of the input.
New Input table:
let
Source = <whatever you're source currently is>,
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type)
in
#"Added Index"
New expanded table:
let
Source = Input,
#"Split Column by Delimiter" = Table.SplitColumn(Source, "INPUT", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"INPUT.1", "INPUT.2", "INPUT.3", "INPUT.4", "INPUT.5", "INPUT.6", "INPUT.7", "INPUT.8", "INPUT.9", "INPUT.10"}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Split Column by Delimiter", {"Index"}, "Attribute", "Value"),
#"Duplicated Column" = Table.DuplicateColumn(#"Unpivoted Other Columns", "Value", "NumberToSum"),
#"Extracted Text After Delimiter" = Table.TransformColumns(#"Duplicated Column", {{"NumberToSum", each Text.AfterDelimiter(_, "-"), type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Extracted Text After Delimiter",{"Attribute"}),
#"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"NumberToSum", Int64.Type}})
in
#"Changed Type"
Now we have that we can join the tables on Index
Now the SUM measure is a simple sum
DAX aims principally at processing well-formed dataset; use Power Query to achieve your goal,
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTQNdQx1DVUitUBcoBsYyA2wuTrGBrrGsEFjXSNQBJgvimQDTNFxwyqwxKkOBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [INPUT = _t]),
Custom1 = Table.AddColumn(Source, "Sum", each List.Sum(List.Transform(Text.Split([INPUT], ","), each Number.From(Text.AfterDelimiter(_, "-")))))
in
Custom1
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
12 | |
10 | |
10 | |
6 |