cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

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 ACCEPTED SOLUTION
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]),
IF ( __Sum < 0 , 0, __Sum)
)
)
``````

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

Thanks a lot for the help !

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]),
IF ( __Sum < 0 , 0, __Sum)
)
)
``````

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

Do you want to just sum the positive values?

Frequent Visitor

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.

Resolver II

See if this example helps you.

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

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors