Forum Discussion

WardWijngaert's avatar
WardWijngaert
Frequent Visitor
3 years ago
Solved

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: ...
  • lbendlin's avatar
    3 years ago

    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.

  • v-yanjiang-msft's avatar
    3 years ago

    Hi WardWijngaert ,

    According to your description, here's my solution.

    Sample:

    1.Create a field parameter containing all the columns.

    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:

    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.