Forum Discussion

Optimusprime_25's avatar
Optimusprime_25
Icon for Resolver I rankResolver I
3 years ago
Solved

How to Sort Sub Header in Switch Case in DAX

I have to sort the sub header columns  values = var ABC_MTD var ABC_YTD var XYZ_MTD var XYZ_YTD RETURN SWITCH( MAX(Table[Sub_Header]), "MTD", ABC_MTD, "YTD", ABC_YTD, "MTD", XYZ_MTD, "YT...
  • Optimusprime_25's avatar
    3 years ago

    I have found the solution for this topic.

    In above case we have sub headers are repeating as MTD and YTD for 8 columns.

    What we did was in switch function we have used space for MTD and YTD so that each and every sub ehader will be unique

     

    Ex: 1. "MTD", "YTD"

         2. " MTD", " YTD"

         3. "  MTD", "  YTD"

     

    We have given extra space so that dax considers each sub header as unique and sort accordingly.