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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
leandrocsouza
Frequent Visitor

Sum the total for a column showing the values ​​in the column, but if the number is negative, show 0

Good morning,
I need to add up the column, but if the total is negative, I have to show zero.
But in the column must appear the negative numbers.
I tried to make this measurement, but it's giving me 0,00 in the column and I can't show the negative number.

Medida = IF(SUM('TABELA REPASSE'[SALDO - FORÇAS ESTADUAIS]) < 0 , 0, SUM('TABELA REPASSE'[SALDO - FORÇAS ESTADUAIS]))
 
1.png

Thank you for your help

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@leandrocsouza 

If you have a category column use it in place of SALDO - FORÇAS ESTADUAIS inside INSCOPE.

Medida =
VAR __Sum =  SUM ( 'TABELA REPASSE'[SALDO - FORÇAS ESTADUAIS] ) 
Return
IF(
    ISINSCOPE ( TABELA REPASSE'[SALDO - FORÇAS ESTADUAIS]),
    TABELA REPASSE'[SALDO - FORÇAS ESTADUAIS],
    IF ( __Sum < 0 , 0, __Sum)
    )
)

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

5 REPLIES 5
leandrocsouza
Frequent Visitor

Thanks a lot for the help ! 
OBRIGADO ! 😁

Fowmy
Super User
Super User

@leandrocsouza 

If you have a category column use it in place of SALDO - FORÇAS ESTADUAIS inside INSCOPE.

Medida =
VAR __Sum =  SUM ( 'TABELA REPASSE'[SALDO - FORÇAS ESTADUAIS] ) 
Return
IF(
    ISINSCOPE ( TABELA REPASSE'[SALDO - FORÇAS ESTADUAIS]),
    TABELA REPASSE'[SALDO - FORÇAS ESTADUAIS],
    IF ( __Sum < 0 , 0, __Sum)
    )
)

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

PietroFarias
Resolver II
Resolver II

Do you want to just sum the positive values?

I want to add up all the values, positive and negative. But if the total is negative, I want to show 0.

But column information must remain negative numbers.


See if this example helps you.

PietroFarias_0-1635171843818.png

PietroFarias_1-1635171893919.png

 

Medida =
VAR ListItens =
    VALUES ( Tabela1[ID] )
VAR Result =
    IF (
        HASONEVALUE ( Tabela1[ID] ),
        SUM ( Tabela1[VALOR] ),
        0
    )
RETURN
    Result

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.