Forum Discussion

DeepakSharma_01's avatar
DeepakSharma_01
Frequent Visitor
1 year ago
Solved

RANKX Dax function behavior with different column from same table

Hi all,   I have written a DAX to rank a measure, which I'll use with different columns but the result is Orpos_item_ID is working fine but with other columns from the same table it is not working....
  • shafiz_p's avatar
    1 year ago

    Hi DeepakSharma_01  You could try ISINSCOPE function to evaluate current dimention and rank. See an example code:

     

    Rank = 
    VAR CurrentDimensionRank = 
        SWITCH(
            TRUE(),
            ISINSCOPE(DimProduct[Color]), RANKX(ALL(DimProduct[Color]), [Revenue], ,DESC, Dense),
            ISINSCOPE(DimProduct[ModelName]), RANKX(ALL(DimProduct[ModelName]), [Revenue], ,DESC, Dense),
            ISINSCOPE(DimProduct[ProductLine]), RANKX(ALL(DimProduct[ProductLine]), [Revenue], ,DESC, Dense)
        )
    RETURN
    CurrentDimensionRank

     

     

    This measure will work for all 3 dimention color, ModelName, and ProductLine.


    Hope this helps!!

    If this solved your problem, please accept it as a solution and a kudos!!

     

     

    Best Regards,
    Shahariar Hafiz