Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
So I want to calculate my total sales, but I only want to do it for products that have more than one entry in my database.
I tried to define my measure as
MS_cond = IF(COUNT('products'[name]) > 1,
SUM('products'[items_per_day]),
"")but it always goes into the ELSE part for every product, even though
items_count = COUNT('products'[name])on its own returns plenty of products with more than one entry. What am I doing wrong?
Solved! Go to Solution.
Can you give this a try? It should build the list of product with > 1 count and return the amount for just those.
MS_Cond =
VAR _ProductsWithCount =
ADDCOLUMNS (
VALUES ( 'products'[name] ),
"@Count", CALCULATE ( COUNT ( 'products'[name] ) )
)
VAR _MultiProducts =
FILTER ( _ProductsWithCount, [@Count] > 1 )
RETURN
CALCULATE ( SUM ( 'products'[items_per_day] ), _MultiProducts )
Can you give this a try? It should build the list of product with > 1 count and return the amount for just those.
MS_Cond =
VAR _ProductsWithCount =
ADDCOLUMNS (
VALUES ( 'products'[name] ),
"@Count", CALCULATE ( COUNT ( 'products'[name] ) )
)
VAR _MultiProducts =
FILTER ( _ProductsWithCount, [@Count] > 1 )
RETURN
CALCULATE ( SUM ( 'products'[items_per_day] ), _MultiProducts )
This works beautifully, thank you! I would never have thought of that by myself!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 39 | |
| 37 | |
| 29 | |
| 24 |
| User | Count |
|---|---|
| 119 | |
| 100 | |
| 72 | |
| 69 | |
| 65 |