Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello, I am trying to figure out how to implement with DAX
Consider the following matrix, where some column names start with e.g. “Field”
Date | Category | Type | Field1 | Field2 | Field3 | Field4 | Field5 | Field6 | Field7 |
dd/mm/yyyy | A | Peak | Value1 | ||||||
dd/mm/yyyy | B | OffPeak | Value2 | Value3 | Value33 | ||||
dd/mm/yyyy | C | Revenue | Value44 | Value15 | Value16 | Value18 | Value20 | Value22 | Value25 |
dd/mm/yyyy | C | Other | Value3 | Value25 | Value85 | Value45 | Value40 | Value41 | |
dd/mm/yyyy | A | Other | Value55 | Value56 | Value68 | Value78 | Value7 |
I would like to count for each Category A, B, C how many values are in the column named “Fieldxx” with xx that could vary from 1 to n.
In the example the result is
Category | Count |
A | 6 |
B | 3 |
C | 13 |
Thank you for your support. Bye
Solved! Go to Solution.
Hi @flyingfox ,
Thank you for your reply. You can still use this method, just change the selected columns in the step to the first three fixed columns and use the unpivot other column function, so that this method applies no matter how many FiledXXs come after that.
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @flyingfox ,
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:
1. Open power query and select all the "Fieldxx" columns, right-click, and choose Unpivot Columns.
2.Close and apply and create a meaure
CountValuesByCategory =
SUMX(
VALUES('Table'[Category]),
CALCULATE(
COUNTROWS('Table'),
'Table'[Value] <> BLANK()
)
)
3.Final output
Thank you for your solution. Unpivoting the columns could work, but I should repeat manually these steps whenever I had to elaborate a new table with a different number of columns named “Fieldxx”. Do you have any other suggestions in order to avoid to execute unpivot specific columns?
Hi @flyingfox ,
Thank you for your reply. You can still use this method, just change the selected columns in the step to the first three fixed columns and use the unpivot other column function, so that this method applies no matter how many FiledXXs come after that.
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
23 | |
10 | |
10 | |
9 | |
7 |