Forum Discussion

rbks's avatar
rbks
Frequent Visitor
2 years ago
Solved

Top 1 with 2 measures.

I got fact table that contains names, sales rate, outlet names.  I got a dimension table contains name list.  And I got 2 measure. One of them counting distinct outlet names. Other one average of s...
  • Sahir_Maharaj's avatar
    2 years ago

    Hello rbks,

     

    Can you please try this:

    Top Name with Conditions = 
    VAR OutletThreshold = 50
    VAR FilteredNames = FILTER(
        ADDCOLUMNS(
            SUMMARIZE(
                'FactTable', 
                'DimensionTable'[Name], 
                "TotalOutlets", [Total outlet number], 
                "AvgRate", [AVG Rate]
            ),
            "Country", RELATED('DimensionTable'[Country])
        ),
        [TotalOutlets] > OutletThreshold
    )
    VAR TopName = TOPN(
        1, 
        FilteredNames, 
        [AvgRate], 
        DESC
    )
    VAR ResultName = MAXX(TopName, 'DimensionTable'[Name])
    
    RETURN
    ResultName
    

    Hope this helps!