Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Power BI DAX

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

OUTPUTSUM

10-1,1-1

2
1-1,3-1,2-13
1-1,3-1,2-1,13-25
1-1,2-2,3-14
5-2,10-1,1-1,6-1,3-1,9-28

 

I need to achieve this result by DAX 

steps:

1. first i need to get the value after (-)

2. then sum of that val

2 REPLIES 2
PaulOlding
Solution Sage
Solution Sage

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"

PaulOlding_4-1624615742842.png

 

Now we have that we can join the tables on Index

PaulOlding_1-1624615579758.png

 

Now the SUM measure is a simple sum

SUM = SUM('Fact'[NumberToSum])
 
and you get your desired result
PaulOlding_3-1624615677533.png

 

 

CNENFRNL
Community Champion
Community Champion

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

Screenshot 2021-06-25 113551.png


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!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.