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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
jas2728
Frequent Visitor

Multiple If statement

Hi All,

I need some help with a below scenario. 

 

Sale Order      Sales      PURCH Id       Purchase 

SO-92345     25,000     PO-233443       25,000

SO-92346    -25,000     PO-233443      25,000 

SO-92347     25,000      PO-233443      25,000   

Total:            25,000                            75,000                            

 

Intended Result: 

 

Sale Order      Sales      PURCH Id       Purchase 

SO-92345     25,000     PO-233443      25,000

SO-92346    -25,000     PO-233443   -25,000 

SO-92347     25,000      PO-233443     25,000 

Total:            25,000                            25,000        

 

I am using below measure to correct the total of the purchase amounts, Is there a way i can use a statement which checks if the sales amount is negative then to multiply the  Purchase value with -1 in the same statement ?

 

Please help.

 

 

Correct total purchase = if (HASONEVALUE(CUSTINVOICEJOUR[SALESID]),
   [Total purchase],SUMX(VALUES(CUSTINVOICEJOUR[SALESID]),[Total purchase]))

 

Thanks,

3 REPLIES 3
MFelix
Super User
Super User

Hi @jas2728 ,

 

Why don't you se the absolute value on your calculation:

 

Correct total purchase =
IF (
    HASONEVALUE ( CUSTINVOICEJOUR[SALESID] ),
    [Total purchase],
    SUMX ( VALUES ( CUSTINVOICEJOUR[SALESID] ), ABS ( [Total purchase] ) )
)

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi MFelix,

Actully the amount in the purchase table is positive, i wanted to see if i can handle the case in BI and convert the repeating value to negative.

Hi @jas2728 ,

 

can you explain a little bit better what you want to achieve? In your example all your values are 25K so difficult to understand how it gives you the negative.

 

What is the rule for multiplying for -1.

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors