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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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