Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Sort Slicer by a date descending

I have a slicer with two columns: quarter and month Format is 2024-Q1 or 2024-01 respectively.   Now In the slicer I want it to show quarter from most recent to earliest, and months from most rece...
  • PowerBIDave's avatar
    PowerBIDave
    1 year ago

    Anonymous 

     

    It would appear that you've omitted an extra pair of parentheses around the sub-formula.

     

    The two snippets of code you provided should be as follows.

     

    The Quarter number forumla:


    Temp_Yr_Quart_Num = 1000000 - (YEAR(dim_date[PK_Date])*100 + QUARTER(dim_date[PK_Date]))

     

    Then, the Month number formula:

     

    Temp_Yr_Mth_Num = 1000000 - (YEAR(dim_date[PK_Date])*100 + MONTH(dim_date[PK_Date]))

     

    Used as the sorting coulmns for your quarter and month columns this should work.

     

    Failing that, try creating the "Year Quarter" and "Year Month" fields as described in my previous message.

     

    Hope that helps.

     

    If this answers your question, please mark as a solution so others can find.