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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Creating a table with frequency of counts

Hi all, 

 

I have a table like this (Table1): 

 

IDColorTextureTaste
S1123
S2345
S3225
S4345
S5544

 

And I need a table like this : 

 

 12345
Color11201
Texture02030
Taste00113

 

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? 

 

 

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@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

 

frequency.png

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.