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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
BLM
Helper I
Helper I

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

 

casea.jpg

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

 

 

Case B:

 

caseb.jpg

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?????  Smiley Frustrated

 

thank you.

 

 

1 ACCEPTED SOLUTION

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.

View solution in original post

6 REPLIES 6
PaulDBrown
Community Champion
Community Champion

@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)





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






v-jiascu-msft
Microsoft Employee
Microsoft Employee

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.

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.

acumulado.jpg

Hi @BLM,

 

Could you please mark the proper answer as solution?

 

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.

Thank u so much. It’s the Best forum

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.

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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