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
OSS
Helper III
Helper III

IF function problem

Dear members

 

Actually I want to perform very simple task.

 

I have 'Account number' and 'Amount' column in my table. I would like to create new column with if condition

 

In Excel, it looks like If(left('Account Number',1)=1, 'Amount', if(left('Account Number',1)=2, 'Amount'*(-1),0)

 

If the first digit of account number is 1 then took the original amount, if the first digit of account number is 2 then took the reverse.

 

I couldn't formulate this condition. Please help me. 

2 ACCEPTED SOLUTIONS
PattemManohar
Community Champion
Community Champion

@OSS Please try this..

 

NewAmount = IF(LEFT(Test181[Account],1)="1",Test181[Amount],IF(LEFT(Test181[Account])="2",Test181[Amount]*-1,0))

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

Anonymous
Not applicable

hi,

 

shouldnt it be like this:

 

NewAmount = IF(LEFT(Test181[Account],1)="1",Test181[Amount],IF(LEFT(Test181[Account],1)="2",Test181[Amount]*-1,0))

 

View solution in original post

6 REPLIES 6
PattemManohar
Community Champion
Community Champion

@OSS Please try this..

 

NewAmount = IF(LEFT(Test181[Account],1)="1",Test181[Amount],IF(LEFT(Test181[Account])="2",Test181[Amount]*-1,0))

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

hi,

 

shouldnt it be like this:

 

NewAmount = IF(LEFT(Test181[Account],1)="1",Test181[Amount],IF(LEFT(Test181[Account],1)="2",Test181[Amount]*-1,0))

 

@Anonymous @OSS

Thanks for that !! But anyway, the second parameter for LEFT function is optional. By default it will take 1 if we don't specify.

 

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

cheers ok, i didn't know that

 

thanks

Thank you for warning, Theo. 1 is forgotten in the formula. Thank you for correction. It would help to avoid confuse if anyone would like to use this formula.

Thank you very much Pattem. I wrote the same formula but forgot ""

That is why my formula wasn't accepted 🙂

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.