Forum Discussion

Pranali_R's avatar
Pranali_R
Frequent Visitor
3 years ago

How to rank two fields using rankx

I am trying to create a visual like this. 

I am unable to rank transaction count and amount at the same time. When users input how many top N entries they want to see, the count and amount should be ranked dynamically

 

Number of entries =
VAR SelectedTop = SELECTEDVALUE('TopN'[TopN ])
RETURN
SWITCH(TRUE(),
RANKX (
ALLSELECTED( Query[CPO NAME] ),
[Count]
)
<= SelectedTop,[Count]
)

5 Replies

  • Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

  • v-zhangti's avatar
    v-zhangti
    Icon for Community Support rankCommunity Support

    Hi, Pranali_R 

     

    Can you provide sample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures. I look forward to your response.

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Pranali_R's avatar
    Pranali_R
    Frequent Visitor

    v-zhangti 

    Mahesh0016 

     

    Here is the sample data.  I want to create a topN slicer based on the total of transaction amount and Transaction Count. Based on the number of entries selected it should show me only those number of records.

    Example if I Select Number of Entries as 1,

    The visual should display C1 with count as 5 and 15100

     

    Car IDCar Park IDtransaction amountTotal  of transaction amountTransaction count
    C1C1011000151005
    C1C1021500
    C1C1032500
    C1C1042300
    C1C1057800
    C2C2014537032
    C2C202250
    C3C2031005503
    C3C204450
    C3C2052400
    C4C11011000110001
    C5C234100010001

     

    Input :

     

    Output :

     

      • Pranali_R's avatar
        Pranali_R
        Frequent Visitor

        Mahesh0016 

         

        I am using the Top N Dynamic What if Parameter  approach to rank and filter the entries.

        But using this.. I am able to just filter on one attribute ..either transaction count or transaction amount.

         

        Number of entries =
        VAR SelectedTop = SELECTEDVALUE('TopN'[TopN ])
        RETURN
        SWITCH(TRUE(),
        RANKX (
        ALLSELECTEDQuery[CPO NAME] ),
        [Count]
        )
        <= SelectedTop,[Count]
        )