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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Leo_Tribaldo
Frequent Visitor

CALCULATE (IF

Hola,

 

He creado una medida para calcular el % de merma teniendo en cuenta la fecha de produccion. La formula es diferente dependiendo de la fecha. He creado esta medida pero no me funciona:

producido_%_Primera_Techlam_COMBINADA =

VAR _Despues=
CALCULATE(
        VAR _CantidadMerma_CantidadConErrores = [Producido_Totalm2_Merma_TechLAM]
        VAR _CantidadPrimera = [Producido_SUMX_Totalm2_Primera]
        VAR _CantidadSegunda = [Producido_SUMX_Totalm2_Segunda]
        VAR _Total = _CantidadMerma_CantidadConErrores+_CantidadPrimera+_CantidadSegunda


        RETURN
            IF(
                _Total = 0,
                BLANK(),
                DIVIDE(_CantidadPrimera,_Total)
            ),
             Producido[Fecha Turno]> DATE(2024,02,16)
)
VAR _Antes =
CALCULATE(  
            VAR _CantidadMerma_CantidadConErrores = [Producido_Totalm2_CantidadConErrores_Primera]
            VAR _CantidadPrimera = [Producido_SUMX_Totalm2_Primera]
            VAR _CantidadSegunda = [Producido_SUMX_Totalm2_Segunda]
            VAR _Total = _CantidadMerma_CantidadConErrores+_CantidadPrimera


            RETURN
                IF(
                    _Total = 0,
                    BLANK(),
                    DIVIDE(_CantidadPrimera,_Total)
                ),


    Producido[Fecha Turno] <= DATE(2024,02,16)
)
VAR _SelectedValue =
SELECTEDVALUE(Producido[Fecha Turno])
RETURN
        IF(
        _SelectedValue > DATE(2024,02,16),_Despues,
        _Antes)   
El resultado de la medida es el siguientes, os marco en amarillo que a partir de la fecha del 16/02/2024 no me calcula el agrupado por semana, pero si lo calcula por día.
Leo_Tribaldo_0-1715253724582.png

Muchas gracias

5 REPLIES 5
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Dear @lbendlin 
Thank you for your support.

This is the link: 
https://drive.google.com/drive/folders/11lpCS0zGxhJaykg0k45LDsaynb3AnlMp?usp=drive_link

Thank you

Link asks for access - please verify

Hi, @lbendlin 
Sorry, this is the first time I post a link
Please, try again 
https://drive.google.com/drive/folders/11lpCS0zGxhJaykg0k45LDsaynb3AnlMp?usp=sharing
Thanks

Leo

It's accessible now, but rather hard to read/comprehend. Can you explain the columns of the Producido table?  Which columns are important and which can be omitted for the scenario? Do I need to worry about negative error numbers?

Which columns do you actually need from the Calendar table?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.