Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

DAX Measure Sort by issue

I have a card on a report page that displays selected choices from slicers and I am having an issue obtaining the correct sort order for one of them. The measure is based on a simple table of two col...
  • Greg_Deckler's avatar
    Greg_Deckler
    6 years ago

    Anonymous - Here is where you are limiting your table. I would replace what is in red bold below with this:

     

    'Grade_Sort_Order'

     

    So, just the table, which would include all columns in the table.

     

    VAR __DISTINCT_VALUES_COUNT = DISTINCTCOUNT('Grade_Sort_Order'[Grade])
    VAR __MAX_VALUES_TO_SHOW = 17
    RETURN
        IF(
            __DISTINCT_VALUES_COUNT <> __MAX_VALUES_TO_SHOW,
            CONCATENATE(
                CONCATENATEX(
                    TOPN(
                        __MAX_VALUES_TO_SHOW,
                        VALUES('Grade_Sort_Order'[Grade]),
                        'Grade_Sort_Order'[Grade],
                        ASC
                    ),
                    'Grade_Sort_Order'[Grade],
                    ", ",
                    'Grade_Sort_Order'[Grade],
                    ASC
                ),
                ""
            ),
                "All"
            )