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

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.

Reply
Anonymous
Not applicable

Distinct count of values from group A that do not exist in group B

Hi Everyone!

 

I'm struggling a long time with the following issue: 

I have 2 groups of items that I calculated - > A and B.

I need to count all distinct values from Group B that do not exist in group A -> Group C.

The following query will demonstrate it:

 

New group - C =
VAR A =
CALCULATE(VALUES(order[Material_Number]),
FILTER(order,order[Upsale_Amount]=0)
)

VAR  B =
CALCULATE(VALUES(order[Material_Number]),
FILTER(order,order[Upsale_Amount]>=1))
 
VAR C = IF(VALUE(UpSale_Items)=VALUE(Origin_Items),0,1)
return C
 
The last part of the query (var c) causing the issue.
When I add the measure to a table it says that the query returns multiple values instead of one. 
 
Anyone has any idea how to solve it?
1 ACCEPTED SOLUTION

@Anonymous 

Please try now, I didn't test it, 

New group Measure =
VAR A = CALCULATETABLE (VALUES(order[Material_Number]),  order[Upsale_Amount] = 0)
VAR B = CALCULATETABLE (VALUES(order[Material_Number]), order[Upsale_Amount] >=1)
VAR C =  COUNTROWS( DISTINCT ( EXCEPT ( A , B ) ) )
RETURN
C

Switch A and B within EXCEPT if you don't get the results. 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

6 REPLIES 6
Fowmy
Super User
Super User

@Anonymous 

Not sure if you need a new table or measure, 

For distinct count measure use the following:

New group Measure =
VAR A = CALCULATETABLE (VALUES(order[Material_Number]),  order[Upsale_Amount] = 0)
VAR B = CALCULATETABLE (VALUES(order[Material_Number]), order[Upsale_Amount] >=1)
VAR C =  DISTINCTCOUNT ( EXCEPT ( A , B ) )


For Table:

New group Table =
VAR A = CALCULATETABLE (VALUES(order[Material_Number]),  order[Upsale_Amount] = 0)
VAR B = CALCULATETABLE (VALUES(order[Material_Number]), order[Upsale_Amount] >=1)
VAR C =  EXCEPT ( A , B )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Hi Fowmy!

 

Thanks for your response. 

I tried the measure you created but the last line of the query returns an error. 

 

KatyaK_1-1633328255967.png

 

 

@Anonymous 
If you need a measure, you need to use the first code block that I shared, for the table, you the 2nd one

Fowmy_0-1633329388942.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Yeh I know, what I'm tring to say that I get an error in the syntax of the measure. 

It doesn't let me to use distinctcount - as showcased in the image I added in my previous answer. 

@Anonymous 

Please try now, I didn't test it, 

New group Measure =
VAR A = CALCULATETABLE (VALUES(order[Material_Number]),  order[Upsale_Amount] = 0)
VAR B = CALCULATETABLE (VALUES(order[Material_Number]), order[Upsale_Amount] >=1)
VAR C =  COUNTROWS( DISTINCT ( EXCEPT ( A , B ) ) )
RETURN
C

Switch A and B within EXCEPT if you don't get the results. 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Thanks a lot it works!!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors