Forum Discussion

mp390988's avatar
mp390988
Post Partisan
1 year ago
Solved

How does RANKX work in a calculated column

Hi,   I am trying to wrap my head around on how the RANKX function behaves in a calculated column. For example, I have the below table where I have added a RANKX function inside a calculated colum...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi mp390988,

    Thank you for reaching out in Microsoft Community Forum.

    Thank you burakkaragoz  for the helpful response.

    Please follow below steps How RANKX Assigns Ranks in a Calculated Column;

    Create a simple calendar table with Financial Year (FY) information.

    Dim Date =
    ADDCOLUMNS(
    CALENDAR(DATE(2024, 1, 1), DATE(2026, 12, 31)),
    "Month", FORMAT([Date], "MMM"),
    "Month Sort", MONTH([Date]),
    "Qtr", "Q" & FORMAT([Date], "Q"),
    "FY", "FY " &
    IF(MONTH([Date]) <= 3,
    YEAR([Date]) - 1 & "-" & YEAR([Date]),
    YEAR([Date]) & "-" & YEAR([Date]) + 1
    )
    )

    Calculated column to rank the FYs.

    FY Order =
    RANKX(
    'Dim Date',
    'Dim Date'[FY],
    ,
    DESC,
    DENSE
    )

     

    Add a Table visual.

    Drag the following fields into the visual:
    - Date
    - Month
    - Qtr
    - FY
    - FY Order (the calculated column)

    Please find the attached .pbix file for your reference. 

    If this post helps in resolve your issue, kindly consider marking it as "Accept as Solution" and give it a 'Kudos' to help others find it more easily.

    Regards,
    Pavan.