cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper III

## top selling product per region but with additional filtering of virtual table

Hello All,

I am trying to replicate the logic from this blog -> https://blog.enterprisedna.co/discover-your-top-products-per-region-in-power-bi-wdax/

where the following logic is used:

to produce the following:

However I would now like to take things further... how might one adapt this logic to only analyse those products where the quantity sold was more than 100 for example?

My thinking is that I create a virtual table of these products only, along the lines of:

``````VAR _table = ADDCOLUMNS(VALUES(Products[Product Name]), "Count", CALCULATE(SUM(Sales[Quantity]))

VAR _filteredtable = FILTER(_table, [Count] > 100)``````

I am stumped however as to how to then use this _filteredtable within the TOPN function as I cannot apply the ALL function to a virtual table.

Cannot anyone help solve this problem? Thanks.

1 ACCEPTED SOLUTION
Super User

Try

``````Top 2 Product Per Region =
VAR RankingContext =
VALUES ( 'Product'[Product Name] )
RETURN
CALCULATE (
[Total Sales],
TOPN (
2,
FILTER (
ALL ( 'Products'[Product Name] ),
CALCULATE ( SUM ( Sales[Quantity] ) ) > 100
),
[Total Sales]
),
RankingContext
)
``````
2 REPLIES 2
Super User

Try

``````Top 2 Product Per Region =
VAR RankingContext =
VALUES ( 'Product'[Product Name] )
RETURN
CALCULATE (
[Total Sales],
TOPN (
2,
FILTER (
ALL ( 'Products'[Product Name] ),
CALCULATE ( SUM ( Sales[Quantity] ) ) > 100
),
[Total Sales]
),
RankingContext
)
``````
Helper III

perfect! simpler than expected.

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors