Forum Discussion

rdg515's avatar
rdg515
Resolver I
4 years ago
Solved

Parameter: Fields selected value

I want to create a measure that references the selected value from a paramater table (create new parameter, select fields). I will show you the way I did it below, but I'm looking for an improvement ...
  • v-kkf-msft's avatar
    4 years ago

    Hi rdg515 ï¼Œ

     

    Please try the measure.

     

    Selected Survey Avg Rating = 
    SWITCH (
        SELECTEDVALUE ( prmSurveyResponses[prmSurveyResponses Fields] ),
        NAMEOF ( 'Service Survey'[NPSResponseCode] ), [NPS Avg Rating],
        NAMEOF ( 'Service Survey'[CustomerEffortResponseCodeText] ), [Customer Effort Avg Rating],
        NAMEOF ( 'Service Survey'[ProductCompetitionResponseCodeText] ), [Product Competition Avg Rating]
    )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • rdg515's avatar
    4 years ago

    Thanks, but I was looking for a way to avoid referencing the parameter table in the Avg Rating measure because I had many measures like this that I had to update when I changed the name of the parameter table.  Having said that, I realized I missed an obvious solution which was to just do this in two steps and if I had to change the paramater table name again I'd just have to do it for one measure.

     

    Step 1:

    Selected Parameter = SELECTEDVALUE ( prmSurveyResponses[prmSurveyResponses Fields] )

     

    Step 2:

    Selected Survey Avg Rating =
    SWITCH (
        [Selected Parameter],
        NAMEOF ( 'Service Survey'[NPSResponseCode] ), [NPS Avg Rating],
        NAMEOF ( 'Service Survey'[CustomerEffortResponseCodeText] ), [Customer Effort Avg Rating],
        NAMEOF ( 'Service Survey'[ProductCompetitionResponseCodeText] ), [Product Competition Avg Rating]
    )

     

    Thanks for the tip to use NAMEOF instead of using double quotes around the column name.

     

    P.S. I keep getting the following error when formatting the dax code as HTML/XML code snippit:

    Your post has been changed because invalid HTML was found in the message body. The invalid HTML has been removed. Please review the message and submit the message when you are satisfied.