Forum Discussion

ViralPatel212's avatar
ViralPatel212
Icon for Resolver I rankResolver I
4 months ago
Solved

Ranking KPI card

I have a page with differnent slicers. in the example the table has been sliced with period = q3, Dealer = 107 and Participant = Client 2. the Ranking on the table works perfectly as its ranks Client 2 within group A for Dealer 107 as 2. However i need to show that 2 in a KPI card. Tried to use that measure in a KPI but it returns as 1 always.

this is the dealer Rank (in group) measure: 

Dealer Rank (in Group) =
RANK(DENSE, ALLSELECTED('Dealer Ranking'[Participant]), ORDERBY([Commission 1], DESC, [Participant]))

thanks

viral

  • HI everyone

     

    Thanks for the suggestion!

     

    i was able to figure it out with this dax: 

     

    Dealer Ranking KPI = 
     
    VAR _group = MAX('Dealer Ranking'[Participant Group])
    VAR _dealer = MAX('Dealer Ranking'[Dealer])
    VAR _participant = SELECTEDVALUE('Dealer Ranking'[Participant])
    VAR _currentComm = 
        CALCULATE(
            SUM('Dealer Ranking'[Commission LC - Everyone]),
            'Dealer Ranking'[Participant] = _participant
        )
    VAR _participants = 
        CALCULATETABLE(
            VALUES('Dealer Ranking'[Participant]),
            REMOVEFILTERS('Dealer Ranking'[Participant]),
            KEEPFILTERS('Dealer Ranking'[Participant Group] = _group),
            'Dealer Ranking'[Dealer] = _dealer
        )
    VAR _withComm = 
        ADDCOLUMNS(
            _participants,
            "Comm", CALCULATE(SUM('Dealer Ranking'[Commission LC - Everyone]))
        )
    RETURN
    RANKX(_withComm, [Comm], _currentComm, 0)

17 Replies

  • It would be easier if you have shared an example dataset but without that I gues it has to be something like this:

    Dealer Rank (Card) =
    VAR _SelectedParticipant =
        SELECTEDVALUE ( 'Dealer Ranking'[Participant] )
    VAR _SelectedGroup =
        SELECTEDVALUE ( 'Dealer Ranking'[Participant Group] )
    VAR _RankTable =
        ADDCOLUMNS (
            CALCULATETABLE (
                VALUES ( 'Dealer Ranking'[Participant] ),
                ALLSELECTED ( 'Dealer Ranking'[Participant] ),
                'Dealer Ranking'[Participant Group] = _SelectedGroup
            ),
            "@Comm", CALCULATE ( [Commission 1] )
        )
    RETURN
        COUNTROWS (
            FILTER (
                _RankTable,
                [@Comm] > CALCULATE ( [Commission 1] )
            )
        ) + 1
  • I have a page with differnent slicers. in the example the table has been sliced with period = q3, Dealer = 107 and Participant = Client 2. the Ranking on the table works perfectly as its ranks Client 2 within group A for Dealer 107 as 2. However i need to show that 2 in a KPI card. Tried to use that measure in a KPI but it returns as 1 always.

    this is the dealer Rank (in group) measure: 

    Dealer Rank (in Group) =
    RANK(DENSEALLSELECTED('Dealer Ranking'[Participant]), ORDERBY([Commission 1]DESC[Participant]))

     

    • Ashish_Mathur's avatar
      Ashish_Mathur
      Icon for Super User rankSuper User

      Hi,

      Please share the download link of the PBI file with your measures already written and visuals already built.  Show the problem there clearly.

    • MFelix's avatar
      MFelix
      Icon for Super User rankSuper User

      Hi ViralPatel212 ,

       

      That specific card you are refering has a filter on the specific customer?

      Since you are using the ALLSELECTED it will only have impact on the participants on the query in this matrix you have Client 1 and Client 2 giving you the number 2, being on a card visual the allselected will have the number 1 since the context is different and you only get a single result.

       

      Can you explain what is the intended purpose and how the card is setup in values and filters.

      • ViralPatel212's avatar
        ViralPatel212
        Icon for Resolver I rankResolver I

        Hello MFelix  

         

        The KPI card shows the rank of the currently selected participant's dealer against all other participants in the same Participant Group. It answers: "How well does my dealer rank within my group?"

        Card Setup:

        Filters on the card:

        • Participant Group = [From page slicer]
        • Dealer = [From page slicer]
        • NOTE: NO filter on Participant by default there page will be filtered to client 2

        Values:

        • The ranking measure that compares the current participant's commission against all others in the group

        How it should work: When a user (Client 2) views the report:

        • Page filter shows: Participant Group = "Group A", Dealer = "Dealer 107"
        • The slicer shows they are viewing as "Client 2"
        • The KPI should rank Client 2's commission against Client 1's commission within Group A
        • Result: Rank 2 of 2

        The issue is that the measure needs to evaluate "Client 2's commission vs all participants in Group A" without the Participant slicer restricting what participants are visible to the calculation.

  • HI everyone

     

    Thanks for the suggestion!

     

    i was able to figure it out with this dax: 

     

    Dealer Ranking KPI = 
     
    VAR _group = MAX('Dealer Ranking'[Participant Group])
    VAR _dealer = MAX('Dealer Ranking'[Dealer])
    VAR _participant = SELECTEDVALUE('Dealer Ranking'[Participant])
    VAR _currentComm = 
        CALCULATE(
            SUM('Dealer Ranking'[Commission LC - Everyone]),
            'Dealer Ranking'[Participant] = _participant
        )
    VAR _participants = 
        CALCULATETABLE(
            VALUES('Dealer Ranking'[Participant]),
            REMOVEFILTERS('Dealer Ranking'[Participant]),
            KEEPFILTERS('Dealer Ranking'[Participant Group] = _group),
            'Dealer Ranking'[Dealer] = _dealer
        )
    VAR _withComm = 
        ADDCOLUMNS(
            _participants,
            "Comm", CALCULATE(SUM('Dealer Ranking'[Commission LC - Everyone]))
        )
    RETURN
    RANKX(_withComm, [Comm], _currentComm, 0)
  • is the KPI card impacted by an independent slicers?  You will need to strategically place a REMOVEFILTERS in your measure for the RANK to have an actual table to work with.

     

     

     

    • ViralPatel212's avatar
      ViralPatel212
      Icon for Resolver I rankResolver I

      hi lbendlin 

      Where would i place it? 

      this is what my goal is: 

      The KPI card shows the rank of the currently selected participant's dealer against all other participants in the same Participant Group. It answers: "How well does my dealer rank within my group?"

      Card Setup:

      Filters on the card:

      • Participant Group = [From page slicer]
      • Dealer = [From page slicer]
      • NOTE: NO filter on Participant by default there page will be filtered to client 2

      Values:

      • The ranking measure that compares the current participant's commission against all others in the group

      How it should work: When a user (Client 2) views the report:

      • Page filter shows: Participant Group = "Group A", Dealer = "Dealer 107"
      • The slicer shows they are viewing as "Client 2"
      • The KPI should rank Client 2's commission against Client 1's commission within Group A
      • Result: Rank 2 of 2

      The issue is that the measure needs to evaluate "Client 2's commission vs all participants in Group A" without the Participant slicer restricting what participants are visible to the calculation.

      • lbendlin's avatar
        lbendlin
        Icon for Super User rankSuper User
        the currently selected participant

        see my edited reply.  You will need to explain how you do that in the UI.

  • Hi ViralPatel212 ,


    Thanks for reaching out to Microsoft Fabric Community.

    Just checking in to see if your query is resolved and if any responses were helpful.
    Otherwise, feel free to reach out for further assistance.

    Also to assist better, could you share sample data or sample .pbix file without any sensitive information. You can upload your files to any cloud storage like OneDrive or GoogleDrive and paste the link here with appropriate permissions.

    How to provide sample data in the Power BI Forum - Microsoft Fabric Community

     

    Thank you.