Forum Discussion

akarasick1's avatar
akarasick1
Frequent Visitor
5 years ago
Solved

RANKX and visual level filter

I have a table containing locations [tLocation], another related table containing products [tProduct]. I want to be able to select a single location in a visual filter and see a rank (as a card) of unique product types for that location. New York has two unique product types, and should rank 1 if selected. If Los Angeles or Houston is selected, they have one unique type and should rank as 2. If Chicago is selected, no types and rank of 3. How can I build measures for distinctcount and rank where the count and rank will work whether a selection is made in a filter dropdown or if all are selected.

 

Location
New York
Los Angeles
Chicago

Houston

 

ProductType
Location
ARedNew York
ARedLos Angeles
ARedHouston
BRedNew York
BRedLos Angeles
BRedHouston
CRedNew York
CRedLos Angeles
DBlueNew York
  • Hi akarasick1 

     

    Two measures...

    Product Count = COUNTROWS(Products)
    
    Product Ranking = 
        RANKX(
            ALL(Locations),
            [Product Count],
            [Product Count],
            DESC,
            Skip
        )

     

    You should be able to drop the Product Ranking measure into a card.  Hope this helps!🙂

4 Replies