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,
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!
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 |
---|---|
105 | |
94 | |
75 | |
63 | |
62 |
User | Count |
---|---|
137 | |
105 | |
104 | |
80 | |
63 |