Forum Discussion
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
- Anonymous4 years ago
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]
)
3 Replies
- AnonymousNot 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]
)
- AnonymousNot applicable
Perfect! Thank you james
- tackytechtomMost Valuable Professional
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/