Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

AVERAGE based on columns added into a parameter field

I have a set of columns and want to have another column that averages these for each row. Now the set of columns are in a parameter field, so I still want to have the option to choose which columns ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Thanks for danextian's concern about this issue.

     

    Hi, Anonymous 

    I am glad to help you.

     

    According to your description, first I created three Measure to calculate the average of different fields:

    AvgQS = AVERAGE(Parameter[QA Score])
    AvgRPI = AVERAGE(Parameter[RPI])
    AvgRSI = AVERAGE(Parameter[RSI])


    Then created Fields Parameter with the three fields checked:

     


    At this point my parameter table looks like this:

     


    Then I created a Measure to dynamically fetch the selected parameters while calculating the averages:

    example Rank = 
    VAR _selectedParameter = CONCATENATEX(VALUES(AverageParameter[AverageParameter Fields]), AverageParameter[AverageParameter Fields], ", ")
    RETURN
    SWITCH (
        _selectedParameter,
        "'Parameter'[QA Score]", [AvgQS],
        "'Parameter'[RPI]", [AvgRPI],
        "'Parameter'[RSI]", [AvgRSI],
        "'Parameter'[QA Score], 'Parameter'[RPI]",([AvgQS]+[AvgRPI]) / 2,
        "'Parameter'[QA Score], 'Parameter'[RSI]",([AvgQS]+[AvgRSI]) / 2,
        "'Parameter'[RPI], 'Parameter'[RPI]",([AvgRPI]+[AvgRSI]) / 2,
        "'Parameter'[QA Score], 'Parameter'[RPI], 'Parameter'[RSI]",([AvgQS]+[AvgRPI]+[AvgRSI]) / 3
    )

     

     

    I have attached the pbix file for this example below, I hope it helps.

     

     

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Fen Ling,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.