Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hello. I need to calculate count of bill where bought two or more group of product
For example, I filtered two groups, I need to count the number of bill where there are these 2 groups.
result: CountOfBill = 2
I tried like this but it's don't work =(
CountOfBill =
VAR F1 = IF(ISFILTERED('Sales'[ProductGroup]);FIRSTNONBLANK('Sales'[ProductGroup];TRUE()))
VAR F2 = IF(ISFILTERED('Sales'[ProductGroup]);LASTNONBLANK('Sales'[ProductGroup];TRUE()))
RETURN CALCULATE(DISTINCTCOUNT([BillNumber]);FILTER('Sales';[ProductGroup] = F1 && [ProductGroup] = F2))
Solved! Go to Solution.
Hi @Claster,
The formula below should work in this scenario. ![]()
CountOfBill =
VAR countOfSelectedGroup =
DISTINCTCOUNT ( Sales[ProductGroup] )
RETURN
COUNTROWS (
FILTER (
SUMMARIZE (
Sales,
Sales[BillNumber],
"CountOfGroup", DISTINCTCOUNT ( Sales[ProductGroup] )
),
[CountOfGroup] >= countOfSelectedGroup
)
) + 0
Regards
Hi @Claster,
Based on my test, the formula below should work in your scenario. ![]()
CountOfBill =
COUNTROWS (
FILTER (
SUMMARIZE (
Sales,
Sales[BillNumber],
"CountOfGroup", DISTINCTCOUNT ( Sales[ProductGroup] )
),
[CountOfGroup] >= 2
)
)
Regards
Thanks for help, but almost right
If I chose 3 ProductGroup the CountOfBill should be 0 (zero) because I don't have bill where customer bought 3 group in one bill
I think like this
CountOfBill =
VAR ChouseCountGroup = COUNTROWS(VALUES('Sales'[ProductGroup]))
VAR F =
COUNTROWS (
FILTER(
SUMMARIZE(
'Sales';
Sales[BillNumber];
"CountOfGroup";DISTINCTCOUNT ( Sales[ProductGroup] ));
[CountOfGroup] = ChouseCountGroup)
)
RETURN IF(F>0;F;0)
Hi @Claster,
The formula below should work in this scenario. ![]()
CountOfBill =
VAR countOfSelectedGroup =
DISTINCTCOUNT ( Sales[ProductGroup] )
RETURN
COUNTROWS (
FILTER (
SUMMARIZE (
Sales,
Sales[BillNumber],
"CountOfGroup", DISTINCTCOUNT ( Sales[ProductGroup] )
),
[CountOfGroup] >= countOfSelectedGroup
)
) + 0
Regards
Thank you so much !
Great to help! ![]()
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 55 | |
| 45 | |
| 38 | |
| 16 | |
| 15 |
| User | Count |
|---|---|
| 87 | |
| 68 | |
| 38 | |
| 29 | |
| 26 |