Forum Discussion

spandy34's avatar
spandy34
Icon for Responsive Resident rankResponsive Resident
2 years ago
Solved

TOP 5 Values of a Text Field

Could someone please help me.  I have the table below and I would like a masure that returns the top 3 Industry Names (Column Industry Name New) based on the OBS_VALUE field    The result based on ...
  • EylesIT's avatar
    2 years ago

    spandy34, here is my suggested solution.

    Create the measure below:

    Top 3 Industries = 
        CONCATENATEX(
            TOPN(3,
                SUMMARIZE(
                    YourTable,
                    YourTable[Industry Name New],
                    "OBS", SUM(YourTable[OBS_VALUE]),
                    "MAX_RECORD_OFFSET", max(YourTable[RECORD_OFFSET])
                ),
                [OBS], DESC, [MAX_RECORD_OFFSET], DESC
            ),
            YourTable[Industry Name New], ", ",
            [OBS], DESC, [MAX_RECORD_OFFSET], DESC
        )

     

    Add a Card visual to your report, and drag the newly created measure onto it. With the data you provided, this gives the output below:

     

     

    Note that in your data you have a tie for 3rd place between "Professional, scientific & technical" and "Retail" (both have OBS_VALUE 8000). How should your report handle this situation? In the measure, I have assumed that the industry with the higher RECORD_OFFSET will "win" a tie-break.

     

    Hope this helps.

     

  • spandy34's avatar
    spandy34
    2 years ago

    Hi thank you so much for your response

     

    I tried the DAX and it is returning 

    But I would be expecting Manufacturing, Health, Professional Scientfitc & technical.

     

    Do you have any idea what i may have done wrong?

     

     

     

  • EylesIT's avatar
    EylesIT
    2 years ago

    spandy34, your DAX code above is summing OBS_VALUE from a different table.

    Try replacing

     

    SUM('Business Size_Sector'[OBS_VALUE])

     

    with

     

    SUM('Employment Sector'[OBS_VALUE])

     

     

  • spandy34's avatar
    spandy34
    2 years ago

    Hi EylesIT 

     

    I have carried out some research and found putting UNICHAR10 in the DAX works below:-77

    z4_Top 3 and Others =
        CONCATENATEX(
            topn(3,
            SUMMARIZE(
                'Employment Sector',
                'Employment Sector'[Industry Name New],
                "OBS",SUM('Employment Sector'[OBS_VALUE]),
                "MAX_RECORD_OFFSET", MAX('Employment Sector'[RECORD_OFFSET])
            ),
            [OBS],DESC,[MAX_RECORD_OFFSET], DESC
            ),
            'Employment Sector'[Industry Name New],"," & UNICHAR(10),
            [OBS],DESC,[MAX_RECORD_OFFSET],DESC)