Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi,
is there any way to count the number of columns in a table? (to be displayed in a visual)
I don't see a function that would do this as a measure.
My other idea would be to transpose the table and count rows, but I don't see a function for that either.
Thanks,
Ruben
Solved! Go to Solution.
You can do it in PowerQuery. If you reference your first query as the source you can keep only the first row then unpivot all the columns. In my example I have a table called "data"
let Source = data, #"Kept First Rows" = Table.FirstN(Source,1), #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Kept First Rows", {}, "Attribute", "Value") in #"Unpivoted Columns"
Just make sure to select all the columns before you unpivot.
Then you feed this to the model and do the count off the new table. You could even remove the value column before loading it.
Hi @Anonymous ,
Try this:
1. In Power Query Editor, Duplicate your table.
2. Select all columns and UnPivot.
3. Remove 'Value' column.
4. Remove duplicate rows.
5. Create a measure.
Count of Columns = COUNTROWS ( 'Table (2)' )
6. Hidden 'Table (2)'.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You can do it in PowerQuery. If you reference your first query as the source you can keep only the first row then unpivot all the columns. In my example I have a table called "data"
let Source = data, #"Kept First Rows" = Table.FirstN(Source,1), #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Kept First Rows", {}, "Attribute", "Value") in #"Unpivoted Columns"
Just make sure to select all the columns before you unpivot.
Then you feed this to the model and do the count off the new table. You could even remove the value column before loading it.
You and use the COUNTROWS() function to count rows once you transpose your table
Help when you know. Ask when you don't!
User | Count |
---|---|
84 | |
80 | |
72 | |
71 | |
55 |
User | Count |
---|---|
108 | |
106 | |
93 | |
85 | |
67 |