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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
PSRai
Helper III
Helper III

Formulas

HI All, 

 

I'm fairly new to PowerBI and Im struggling to get a formula to work, Im hoping one of you experts can help me 

 

IF(SUM('Order Data'[DocumentTypeID])=1,(SOPInvoiceCreditLine[LineTotalValue]),(SOPInvoiceCreditLine[LineTotalValue]*-1))
 
If DocumentTypeID is 1 then  *-1 to LineTotalVal
 
I have wrote this formula in PowerBI however its adding a - to all figures and not to the figure that has a condition,
 
Please can someone help?
4 REPLIES 4
d_gosbell
Super User
Super User

The problem is that this formula is not checking the value of DocumentTypeID on a row by row basis, you are adding the DocumentTypeID for all rows and then checking if the sum of those is equal to 1 (which it won't be).

 

The way to solve this is to use SUMX to evaluate this expression on a row by row basis.

 

eg.

 

SUMX('Order Data',
    IF('Order Data'[DocumentTypeID]=1
      , SOPInvoiceCreditLine[LineTotalValue]
      , SOPInvoiceCreditLine[LineTotalValue] * -1)
)

Hi

 

Thanks, I have tried that but still not working, 

Their is a minus figure applied to all figures instead of the one with the condition.

 

See diagram below. 

 

So the very last figure should be a negative also the figures in Line Val ADJ should match those in LineTotalValue

 

Hope you can help 

 

Line Val ADJLine Val ADJ

Hi @PSRai ,

Have you solved your problem?

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

If you still need help, please share some data sample which could reproduce your sceanrio and your desired output so that we could help further on it.

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

What's the relationship between 'Order Data' and 'SOPInvoiceCreditLine' can you post a picture of the table diagram?

 

Is [LineTotalValue] a measure or a column?

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.