Forum Discussion

badger123's avatar
badger123
Icon for Resolver I rankResolver I
7 years ago
Solved

Need help with ranking / finding max category

Hi all, I just can't seem to figure out how to do this... please help! 

 

I would like to display in a table visual ID and Category as columns, where the Category is that with the highest summed volume based on the Text selected. 

 

Desired output in table visual:

IDCategory
Item OneC
Item TwoD

 

Table 1: 

IDTextCategory
Item Onetext oneA
Item Onetext twoA
Item Onetext threeA
Item Onetext fourB
Item Onetext fiveB
Item Onetext sixB
Item Onetext sevenC
Item Onetext eightC
Item Onetext nineC
Item Twotext tenA
Item Twotext oneA
Item Twotext twoC
Item Twotext elevenD
Item Twotext twelveE

 

Table 2:

TextVolume
text one10
text two20
text three30
text four40
text five10
text six20
text seven30
text eight90
text nine100
text ten50
text eleven200
text twelve10
  • badger123 

     

    Assuming Table1 (Many side) is related to Table 2 (One Side) using Text Column

    Try this Measure

     

    Measure =
    CONCATENATEX (
        TOPN (
            1,
            CALCULATETABLE ( VALUES ( Table1[Category] ) ),
            CALCULATE (
                SUM ( Table2[Volume] ),
                CROSSFILTER ( Table1[Text], Table2[Text], BOTH )
            ), DESC
        ),
        [Category],
        ","
    )
    

1 Reply

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Icon for Community Champion rankCommunity Champion

    badger123 

     

    Assuming Table1 (Many side) is related to Table 2 (One Side) using Text Column

    Try this Measure

     

    Measure =
    CONCATENATEX (
        TOPN (
            1,
            CALCULATETABLE ( VALUES ( Table1[Category] ) ),
            CALCULATE (
                SUM ( Table2[Volume] ),
                CROSSFILTER ( Table1[Text], Table2[Text], BOTH )
            ), DESC
        ),
        [Category],
        ","
    )