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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
WardWijngaert
Frequent Visitor

Measures, columns or parameters?

Hello, As a beginner Power BI user I have a configuration dilemma. I have 50 columns with data (values) and want to display the same 3 calculations applied on each column. These 3 calculations are:
1: Percentage of appearance of a specific number (20) in the column
2: Percentage of appearance of another number (14) in the column
3: Sum of the 2 percentages.

I would initially program 3 specific measures for each column, but I think it can be automated, right (if not this will be 150 different measures)? How can I write general measures, without having to specify each time the specific column? I understand that working with parameters I can filter the 3 calculations by the column that suits me, right?

can you help me please?

 

Kind regards.

2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

Unpivot your data. Instead of 50 columns have two - attribute and value.  Then you can write one generic measure, or maybe even solve the question through the user interface.

View solution in original post

v-yanjiang-msft
Community Support
Community Support

Hi @WardWijngaert ,

According to your description, here's my solution.

Sample:

vyanjiangmsft_0-1689584408955.png

1.Create a field parameter containing all the columns.

vyanjiangmsft_1-1689584444116.png

vyanjiangmsft_2-1689584461497.png

2.Creat three measures:

Measure =
VAR _Field =
    SWITCH (
        SELECTEDVALUE ( Parameter[Parameter Fields] ),
        "'Table'[Column1]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column1] = 20 ) ),
        "'Table'[Column2]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column2] = 20 ) ),
        "'Table'[Column3]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column3] = 20 ) )
    )
RETURN
    DIVIDE ( _Field, COUNTROWS ( 'Table' ) )
Measure2 =
VAR _Field =
    SWITCH (
        SELECTEDVALUE ( Parameter[Parameter Fields] ),
        "'Table'[Column1]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column1] = 14 ) ),
        "'Table'[Column2]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column2] = 14 ) ),
        "'Table'[Column3]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column3] = 14 ) )
    )
RETURN
    DIVIDE ( _Field, COUNTROWS ( 'Table' ) )
Measure3 =
[Measure] + [Measure 2]

Put the parameter in a slicer, then get the correct result:

vyanjiangmsft_3-1689587580396.png

vyanjiangmsft_4-1689587644210.png

vyanjiangmsft_5-1689587660627.png

I attach my sample below for your reference.

 

Best regards,

Community Support Team_yanjiang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
WardWijngaert
Frequent Visitor

Great @lbendlin & @v-yanjiang-msft I tried both solutions and they work fine! Thank you very much for your help.

Hi @WardWijngaert ,

If you don't have other problems, please kindly mark the helpful reply as solution, then we'll close the thread, other people who has the same problem will benefit here.

 

Best regards,

Community Support Team_yanjiang

v-yanjiang-msft
Community Support
Community Support

Hi @WardWijngaert ,

According to your description, here's my solution.

Sample:

vyanjiangmsft_0-1689584408955.png

1.Create a field parameter containing all the columns.

vyanjiangmsft_1-1689584444116.png

vyanjiangmsft_2-1689584461497.png

2.Creat three measures:

Measure =
VAR _Field =
    SWITCH (
        SELECTEDVALUE ( Parameter[Parameter Fields] ),
        "'Table'[Column1]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column1] = 20 ) ),
        "'Table'[Column2]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column2] = 20 ) ),
        "'Table'[Column3]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column3] = 20 ) )
    )
RETURN
    DIVIDE ( _Field, COUNTROWS ( 'Table' ) )
Measure2 =
VAR _Field =
    SWITCH (
        SELECTEDVALUE ( Parameter[Parameter Fields] ),
        "'Table'[Column1]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column1] = 14 ) ),
        "'Table'[Column2]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column2] = 14 ) ),
        "'Table'[Column3]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column3] = 14 ) )
    )
RETURN
    DIVIDE ( _Field, COUNTROWS ( 'Table' ) )
Measure3 =
[Measure] + [Measure 2]

Put the parameter in a slicer, then get the correct result:

vyanjiangmsft_3-1689587580396.png

vyanjiangmsft_4-1689587644210.png

vyanjiangmsft_5-1689587660627.png

I attach my sample below for your reference.

 

Best regards,

Community Support Team_yanjiang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Unpivot your data. Instead of 50 columns have two - attribute and value.  Then you can write one generic measure, or maybe even solve the question through the user interface.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.