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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.