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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
TSK
Frequent Visitor

Result based on rows against 1 unique value

I have Order and Name column.. I want to check If against one unique Order  "Name" contains "Ali" and "Saqib" It should return 1 in result coulmn otherwise 0, Just like in followwing example in Order Column only B has "Ali" and  "Saqib" so result should be 1 only for B. How to achieve this?

 

OrderNameResult
AAli0
AMuhammad0
AAshraf0
BAli1
BSaqib1
CAli0
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@TSK 

 

Try this DAX:

Result = 
var Ali = CALCULATE(COUNTROWS(Sheet1),FILTER(ALLEXCEPT(Sheet1,Sheet1[Order]),Sheet1[Name]="ali"))
var Saqib = CALCULATE(COUNTROWS(Sheet1),FILTER(ALLEXCEPT(Sheet1,Sheet1[Order]),Sheet1[Name]="saqib"))
Return IF(Ali>=1 && Saqib>=1,1,0)

 ali&Saqib.JPG

Best Regards

Paul Zheng

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@TSK 

 

Try this DAX:

Result = 
var Ali = CALCULATE(COUNTROWS(Sheet1),FILTER(ALLEXCEPT(Sheet1,Sheet1[Order]),Sheet1[Name]="ali"))
var Saqib = CALCULATE(COUNTROWS(Sheet1),FILTER(ALLEXCEPT(Sheet1,Sheet1[Order]),Sheet1[Name]="saqib"))
Return IF(Ali>=1 && Saqib>=1,1,0)

 ali&Saqib.JPG

Best Regards

Paul Zheng

TSK
Frequent Visitor

Thanks alot, man thats work absolutly perfect, just one more thing, how can I have disticnt count of order wher result is 1, in this case answer is 2 because only B and C have 1 in result column. how can I get this 2?

Anonymous
Not applicable

@TSK 

Once you have your expected [Result] column, you can distinctcount [Order], and set a filter to [Result] column: 

 

Measure = CALCULATE(DISTINCTCOUNT(Sheet1[Order]),FILTER(Sheet1,Sheet1[Result] = 1))
 
Best,
Paul

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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 Kudoed Authors