Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Write a measure to show multiple data formats

Hi team,

I have several metrics with values displayed in different formats, such as decimal or percentage.

Problem: I need to display all metric values in a single column in a table based on the selected metric from a dropdown, which should sort the column accordingly.

How can I get that?

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

     

    Thanks for the reply from Jihwan_Kim .

     

    There is a little problem with your DAX syntax. Since I do not know your [Average People living with HIV recieving ART] and [% CAR By Age] measures, I used the columns directly. This is the adjusted one:

     

    AIIMeasure_text = 
    VAR CurrentIndicator = SELECTEDVALUE('Summary Tab'[Indicator])
    RETURN
    SWITCH (
    TRUE (),
    CurrentIndicator = "Number of People Living with HIV Currently Receiving ART",MAX('Summary Tab'[value]),
    CurrentIndicator = "Contraceptive Acceptance Rate (CAR)",FORMAT(MAX('Summary Tab'[value]) ,"0.0%")  //Assuming the measure is in decimal format
    )

     

     

    Drag the measure to the report page for display.

     

    Select the three dots in the lower right corner, select Sort by, select the measure you created, and select descending order.

     

    pbix file is attached.

     

    I would be grateful if you could provide me with sample data for testing, please remove any sensitive data in advance.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

3 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello,

      Thank you for getting back to me. I've attached a screenshot of the measure I require assistance with.

      Regarding the measures, I aim to display one as a decimal and the other as a percentage, based on the indicator selection. Additionally, I would like the table to be sortable based on the indicator selection.

      For instance, if I select the contraceptive acceptance rate, the table should display as follows:

      Zone     Metric

      A          97%

      B          96%

      C          85%

      D          70%

      I appreciate your assistance with this matter.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        Thanks for the reply from Jihwan_Kim .

         

        There is a little problem with your DAX syntax. Since I do not know your [Average People living with HIV recieving ART] and [% CAR By Age] measures, I used the columns directly. This is the adjusted one:

         

        AIIMeasure_text = 
        VAR CurrentIndicator = SELECTEDVALUE('Summary Tab'[Indicator])
        RETURN
        SWITCH (
        TRUE (),
        CurrentIndicator = "Number of People Living with HIV Currently Receiving ART",MAX('Summary Tab'[value]),
        CurrentIndicator = "Contraceptive Acceptance Rate (CAR)",FORMAT(MAX('Summary Tab'[value]) ,"0.0%")  //Assuming the measure is in decimal format
        )

         

         

        Drag the measure to the report page for display.

         

        Select the three dots in the lower right corner, select Sort by, select the measure you created, and select descending order.

         

        pbix file is attached.

         

        I would be grateful if you could provide me with sample data for testing, please remove any sensitive data in advance.

         

        Best Regards,
        Yang
        Community Support Team

         

        If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
        If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!