Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi, I want to create a combo visual and so the data needed is one common axis column and two values,
the data seems need to be unpivoted and there are many others fiters to be considered, like location and other columns not listed.
I am new user of DAX and ask for help, could this problem can be solved use DAX? Thank you.
Solved! Go to Solution.
Hi @Anonymous ,
Here are the steps you can follow:
1. Use Enter data to create a table.
2. Select the following columns in the power query and use Unpivot Column.
3. Create calculated column.
Table:
left =
LEFT('Table'[Attribute],3)
right = RIGHT('Table'[Attribute],1)
Table2:
Right =
RIGHT('Table2'[Month],1)
4. Create measure.
Bar_measure =
CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[left]="bar"&&'Table'[right]=MAX('Table2'[Right])))
Lin_measure =
CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[left]="lin"&&'Table'[right]=MAX('Table2'[Right])))
5. 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
Hi @Anonymous ,
Here are the steps you can follow:
1. Use Enter data to create a table.
2. Select the following columns in the power query and use Unpivot Column.
3. Create calculated column.
Table:
left =
LEFT('Table'[Attribute],3)
right = RIGHT('Table'[Attribute],1)
Table2:
Right =
RIGHT('Table2'[Month],1)
4. Create measure.
Bar_measure =
CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[left]="bar"&&'Table'[right]=MAX('Table2'[Right])))
Lin_measure =
CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[left]="lin"&&'Table'[right]=MAX('Table2'[Right])))
5. 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
Throw this into your advanced editor
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTIEYmMoNleK1YlWSoLyjKDYFCyaDFJriCRsDBZOAbLMkIwAKomNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [location = _t, bar = _t, bar2 = _t, line = _t, line2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"location", type text}, {"bar", Int64.Type}, {"bar2", Int64.Type}, {"line", Int64.Type}, {"line2", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"location"}, "Attribute", "Value"),
#"Inserted First Characters" = Table.AddColumn(#"Unpivoted Other Columns", "First Characters", each Text.Start([Attribute], 3), type text),
#"Replaced Value" = Table.ReplaceValue(#"Inserted First Characters","bar","Jan",Replacer.ReplaceValue,{"Attribute", "Value"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","bar2","feb",Replacer.ReplaceValue,{"Attribute", "Value"}),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","line","jan",Replacer.ReplaceValue,{"Attribute", "Value"}),
#"Replaced Value3" = Table.ReplaceValue(#"Replaced Value2","line2","feb",Replacer.ReplaceValue,{"Attribute", "Value"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Replaced Value3",{{"Value", Int64.Type}})
in
#"Changed Type1"
Then measure as so:
Same syntax for the line measure just with "lin" in stead
Thanks, it's a good way, but it seems new data source have to be created and has no relation to CONTEXT, so I am seeking a way that use DAX
What?
@Anonymous wrote:Thanks, it's a good way, but it seems new data source have to be created and has no relation to CONTEXT
I don't think you're gonna reach your goal with DAX only. Some unpivoting will be needed.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
82 | |
70 | |
61 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |