cancel
Showing results for
Did you mean:
Highlighted
Regular Visitor

## Table total error

hello,

i've maked a table with several measures. Specifically the measure "afabricar" don't want that show negatives values (if the result it's negative the valued must be zero).

Well, if the measure show negatives values, the "Total" it's Ok, but if I make that the result show zero, the "Total" it's the same, don't changed.

Case A

afabricar =
IF(SUM(Productos[smincorregido])=0;[sminnew];SUM(Productos[smincorregido]))
-[stockactual]
+IF([totalconsumos]<[sminnew];[sminnew];[totalconsumos])
-'ops+stocks+cargas'[opspdts]

Case B:

afabricar = if(
(IF(SUM(Productos[smincorregido])=0;[sminnew];SUM(Productos[smincorregido]))
-[stockactual]
+IF([totalconsumos]<[sminnew];[sminnew];[totalconsumos])
-'ops+stocks+cargas'[opspdts])<0;
0;

IF(SUM(Productos[smincorregido])=0;[sminnew];SUM(Productos[smincorregido]))
-[stockactual]
+IF([totalconsumos]<[sminnew];[sminnew];[totalconsumos])
-'ops+stocks+cargas'[opspdts]
)

What's the problem?????

thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Super Contributor

## Re: Table total error

Hi @BLM,

Try this formula, please. If it still doesn't work, please share your file or a dummy sample.

```afabricar =
VAR temp =
IF (
SUM ( Productos[smincorregido] ) = 0;
[sminnew];
SUM ( Productos[smincorregido] )
)
- [stockactual]
+ IF ( [totalconsumos] < [sminnew]; [sminnew]; [totalconsumos] )
- 'ops+stocks+cargas'[opspdts]
RETURN
IF (
HASONEVALUE ( 'TableName'[codnombre] );
IF ( temp < 0; 0; temp );
SUMX (
SUMMARIZE (
'TableName';
'TableName'[codnombre];
"temp1"; IF (
SUM ( Productos[smincorregido] ) = 0;
[sminnew];
SUM ( Productos[smincorregido] )
)
- [stockactual]
+ IF ( [totalconsumos] < [sminnew]; [sminnew]; [totalconsumos] )
- 'ops+stocks+cargas'[opspdts]
);
[temp1]
)
)```

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
6 REPLIES 6
Super Contributor

## Re: Table total error

Hi @BLM,

The cause is the "Total" has its own context, which doesn't add up the values of the other rows. You try out this formula. If you want a accurate formula, please share your file or a dummy sample.

```afabricar =
VAR temp =
IF (
SUM ( Productos[smincorregido] ) = 0;
[sminnew];
SUM ( Productos[smincorregido] )
)
- [stockactual]
+ IF ( [totalconsumos] < [sminnew]; [sminnew]; [totalconsumos] )
- 'ops+stocks+cargas'[opspdts]
RETURN
IF (
HASONEVALUE ( 'TableName'[codnombre] );
temp;
SUMX (
SUMMARIZE (
'TableName';
'TableName'[codnombre];
"temp1"; IF (
SUM ( Productos[smincorregido] ) = 0;
[sminnew];
SUM ( Productos[smincorregido] )
)
- [stockactual]
+ IF ( [totalconsumos] < [sminnew]; [sminnew]; [totalconsumos] )
- 'ops+stocks+cargas'[opspdts]
);
[temp1]
)
)```

Best Regards,

Dale

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

## Re: Table total error

I'm tryed out your formula, and the result it's the same. Show the negatives values and the "Total" it's Ok, but the question is that don't show the negatives values but 0.

Super Contributor

## Re: Table total error

Hi @BLM,

Try this formula, please. If it still doesn't work, please share your file or a dummy sample.

```afabricar =
VAR temp =
IF (
SUM ( Productos[smincorregido] ) = 0;
[sminnew];
SUM ( Productos[smincorregido] )
)
- [stockactual]
+ IF ( [totalconsumos] < [sminnew]; [sminnew]; [totalconsumos] )
- 'ops+stocks+cargas'[opspdts]
RETURN
IF (
HASONEVALUE ( 'TableName'[codnombre] );
IF ( temp < 0; 0; temp );
SUMX (
SUMMARIZE (
'TableName';
'TableName'[codnombre];
"temp1"; IF (
SUM ( Productos[smincorregido] ) = 0;
[sminnew];
SUM ( Productos[smincorregido] )
)
- [stockactual]
+ IF ( [totalconsumos] < [sminnew]; [sminnew]; [totalconsumos] )
- 'ops+stocks+cargas'[opspdts]
);
[temp1]
)
)```

Best Regards,

Dale

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

## Re: Table total error

@BLM

I understand your measure [afabricar] returns negative values as '0', and positive values stay the same, right?

Try using:

Correct totals for afabricar = SUMX(SUMMARIZE('tableforcodnombre', 'tableforcodnombre'[codnombre]), [afabricar])

(where 'tableforcodnombre' is obviously the lookup table where your 'codnombre' column is; if you don't have a lookup table for codnombre, you'll have to wrap it in VALUES)

Super Contributor

## Re: Table total error

Hi @BLM,

Best Regards!
Dale

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

## Re: Table total error

Thank u so much. It’s the Best forum

Announcements

Power BI Super User, Greg Deckler, explains

#### Power Platform Summit North America

Register by September 5 to save \$200

#### Back to School Contest

Engage and empower students with Power BI!

#### Watch Sessions On Demand!

Continue your learning in our online communities.

Top Ideas
Top Kudoed Authors
Users Online
Currently online: 107 members 1,459 guests
Recent signins: