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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
pcav
Helper I
Helper I

Using Conditions when calculating

I'm sure that there is an easy answer to this one but its alluding me presently and if anybody could shed some light I would be eternally grateful.

 

I have 3 columns in a table, A, B and C, A contains "Y" or "N", B and C contain numerical values

 

I want to create a single measure that gives me the total of B and C depending on the value in A, so if A = "Y" I want to include the value in B and if A = "N" I want to include the value in C in the calculation.

 

I can create 2 measures filtering on each of the conditions and add them up in a 3rd measure and I get the right answer but I feel I ought to be able to do this is a single measure but the syntax alludes me. 

 

Peter

1 ACCEPTED SOLUTION
alexei7
Continued Contributor
Continued Contributor

Hi Peter,

 

See if the below helps you out at all (obviously replacing table and columns names with your own):

 

Measure = sumx(Table1,if(Table1[A]="Y",(Table1[B]),if(Table1[A]="N",(Table1[C]),0)))

 

Thanks

Alex 

View solution in original post

3 REPLIES 3
alexei7
Continued Contributor
Continued Contributor

Hi Peter,

 

See if the below helps you out at all (obviously replacing table and columns names with your own):

 

Measure = sumx(Table1,if(Table1[A]="Y",(Table1[B]),if(Table1[A]="N",(Table1[C]),0)))

 

Thanks

Alex 

Alex, works perfectly.  So simple yet I stuggled with that for hours.   Thanks so much for taking your time out to help me.  I really appreciate it

 

Regards

 

Peter

alexei7
Continued Contributor
Continued Contributor

Glad i could help! 🙂

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors