March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi all,
I have a table like this (Table1):
ID | Color | Texture | Taste |
S1 | 1 | 2 | 3 |
S2 | 3 | 4 | 5 |
S3 | 2 | 2 | 5 |
S4 | 3 | 4 | 5 |
S5 | 5 | 4 | 4 |
And I need a table like this :
1 | 2 | 3 | 4 | 5 | |
Color | 1 | 1 | 2 | 0 | 1 |
Texture | 0 | 2 | 0 | 3 | 0 |
Taste | 0 | 0 | 1 | 1 | 3 |
I created an excel table such as :
Variable |
Color |
Texture |
Taste |
I exported it in Power BI (Table2) and then I thought of adding 5 new columns, such as :
1= VAR Crit = 1 VAR CLR1 = CALCULATE(COUNTROWS(Table1),FILTER(Table1,Table1[Color] = Crit))
VAR CLR2 = IF(CLR1=0,0,CLR1) VAR TXTR1 = CALCULATE(COUNTROWS(Table1),FILTER(Table1,Table1[Texture] = Crit))
VAR TXTR2 =
IF(TXTR1=0,0,TXTR1) VAR TST1 = CALCULATE(COUNTROWS(Table1),FILTER(Table1,Table1[Taste] = Crit)) VAR TST2 =
IF(TST1=0,0,TST1) Return IF(Table2[Variable]="Color",CLR2,IF(Table2[Variable]="Texture",TXTR2,IF(Table2[Variable]="Taste",TST2,0)))
But it doesnt work. It doesnt return any message error, but the column is totally empty. Any ideas?
@Anonymous
With POwer Query, you can use this
let Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"Color", Int64.Type}, {"Texture", Int64.Type}, {"Taste", Int64.Type}}), #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"ID"}, "Attribute", "Value"), #"Duplicated Column" = Table.DuplicateColumn(#"Unpivoted Columns", "Value", "Value - Copy"), #"Removed Columns" = Table.RemoveColumns(#"Duplicated Column",{"ID"}), #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Removed Columns", {{"Value", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Removed Columns", {{"Value", type text}}, "en-US")[Value]), "Value", "Value - Copy", List.Count) in #"Pivoted Column"
@Anonymous
See attached Excel files's Query Editor for steps
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
114 | |
76 | |
57 | |
52 | |
44 |
User | Count |
---|---|
165 | |
116 | |
63 | |
57 | |
50 |