Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to include a filter in a topN dax function?

I want to include a filter in my dax function but not sure how?

 

see below my new table formula (works fine)

 

 

Top5Products = 
TOPN(
    5,
    SUMMARIZE(
        'DimProduct',
        'DimProduct'[ProductFlag],
        'DimProduct'[ProductID],
        'DimProduct'[ProductKey],
        'DimProduct'[ProductName],
        "Products",
        SUM('FctSales'[TotalVolume])
    ),
    [Providers]
)

 

I want to put in a filter that does something like this:

 

FILTER ( DimProduct, 'DimProduct'[ProductFlag] <> "False" )

 

 in other words dont include any products where the product flag is False 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Why dont you add this filter before the summarize

Top5Products =

TOPN(

    5,

    Filter(SUMMARIZE(

        'DimProduct',

        'DimProduct'[ProductFlag],

        'DimProduct'[ProductID],

        'DimProduct'[ProductKey],

        'DimProduct'[ProductName],

        "Products",

        SUM('FctSales'[TotalVolume])

    ),'DimProduct'[ProductFlag]<>"False"),

    [Providers]

)

View solution in original post

3 REPLIES 3
tackytechtom
Super User
Super User

Hi @Anonymous 

 

Does it work with this one?

Top5Products = 
TOPN(
    5,
    SUMMARIZE(
        FILTER ( 'DimProduct', 'DimProduct'[ProductFlag] <> "False" )
        'DimProduct'[ProductFlag],
        'DimProduct'[ProductID],
        'DimProduct'[ProductKey],
        'DimProduct'[ProductName],
        "Products",
        SUM('FctSales'[TotalVolume])
    ),
    [Providers]
)

 

Let me know if this works for you 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Anonymous
Not applicable

Why dont you add this filter before the summarize

Top5Products =

TOPN(

    5,

    Filter(SUMMARIZE(

        'DimProduct',

        'DimProduct'[ProductFlag],

        'DimProduct'[ProductID],

        'DimProduct'[ProductKey],

        'DimProduct'[ProductName],

        "Products",

        SUM('FctSales'[TotalVolume])

    ),'DimProduct'[ProductFlag]<>"False"),

    [Providers]

)

Anonymous
Not applicable

Perfect! Thank you james

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.