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! Request now

Reply
Anonymous
Not applicable

Measure or Calculated Column adding +1 per condition met

Hi all,

 

Per row, I want to check how many conditions the associated data meets.

 

E.g. if I have the following table People:

 

NameCashEye ColorShoe ColorHair Color
John20BrownBrownBlond
Jane80GreenYellowBrown
Doe0BrownYellowBrown

 

I want to do several checks like:

if(cash >50 && eye color == Green), counter +1

if(cash <10 && eye color == Brown), counter +1

if(Shoe Color == Yellow && eye color == Green), counter +1

if(Shoe Color == Brown && eye color == Brown), counter +1

 

Resulting in:

 

NameCashEye ColorShoe ColorHair ColorCounter
John20BrownBrownBlond1
Jane80GreenYellowBrown3
Doe0BrownYellowBrown1

 

 

I know this is possible by creating calculated columns for each check and then adding the results of those calculated columns, but I'd like to contain the complexity within 1 measure/calculated column, rather than spread over the table.

 

Can anyone tell me if this is possible, and if so, how?

 

Thanks in advance!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , not very clear

create a new column =if( [cash] > 50 && [eye color] = "Green",1,0) + if( [cash] <10 && [eye color] = "Brown",1,0) + if( [Shoe Color] "Yellow" && [eye color] = "Green",1,0)
+ if( [Shoe Color] "Brown" && [eye color] = "Brown",1,0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks all! I feel daft now for not think of just adding the if statements together.

Anonymous
Not applicable

Is this what you're looking for?

 

JDIBC_0-1598538484639.png

 

dedelman_clng
Community Champion
Community Champion

Hi @Anonymous 

 

You can create a measure with this general formula pattern:

Counter = 
var __Check1 = COUNTROWS( 
        FILTER (Table, Table[Cash] > 50 && Table[Eye Color] = "Green") )
var __Check2 = COUNTROWS( FILTER (Table, **Check2 Conditions**) )
...
var __CheckN = COUNTROWS( FILTER (Table, **CheckN Conditions**) )

RETURN
__var1 + __var2 + ... + __varN + 0  //The +0 at the end keeps the result from being BLANK

 

Hope this helps

David

 

amitchandak
Super User
Super User

@Anonymous , not very clear

create a new column =if( [cash] > 50 && [eye color] = "Green",1,0) + if( [cash] <10 && [eye color] = "Brown",1,0) + if( [Shoe Color] "Yellow" && [eye color] = "Green",1,0)
+ if( [Shoe Color] "Brown" && [eye color] = "Brown",1,0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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