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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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