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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

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