Forum Discussion

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

TOP N affected by Legend in Bar Graph

Hi All,   I have created a disconnected TOP N table where its got my All my Dealers + a single row called Others, and this has a relationship with the main table Dealer to Dealer. Relationship: ...
  • cengizhanarslan's avatar
    3 months ago

    When you add Participant to the Legend, the visual evaluates your measure for every Dealer + Participant combination. If you do not want it to affect the visual you could try using REMOVEFILTERs() inside your measure:

    Top N Spend =
    VAR _TOPNSelected =
        SELECTEDVALUE ( 'Top N'[TopN] )
    VAR _CurrentDealer =
        SELECTEDVALUE ( 'Counterparty List 2'[Dealer] )
    VAR _TopDealerTable =
        TOPN (
            _TOPNSelected,
            ALLSELECTED ( 'Counterparty List 2' ),
            CALCULATE (
                [Metrics],
                REMOVEFILTERS ( 'Dealer Ranking'[Participant] )
            )
        )
    VAR _IsTopDealer =
        COUNTROWS (
            INTERSECT (
                VALUES ( 'Counterparty List 2'[Dealer] ),
                SELECTCOLUMNS ( _TopDealerTable, "Dealer", [Dealer] )
            )
        ) > 0
    VAR _TopDealerCommission =
        CALCULATE (
            [Metrics],
            KEEPFILTERS ( _TopDealerTable )
        )
    VAR _OtherCommission =
        CALCULATE (
            [Metrics],
            ALLSELECTED ( 'Counterparty List 2' )
        ) -
        CALCULATE (
            [Metrics],
            _TopDealerTable
        )
    RETURN
        IF (
            _CurrentDealer <> "Others",
            IF ( _IsTopDealer, _TopDealerCommission ),
            _OtherCommission
        )