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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Analitika
Post Prodigy
Post Prodigy

Medir simplificar y comprimir

Tengo un montón de medida terrible y compleja de otros proyectos.

¿Hay alguna manera de simplificar y comprimir tales medidas como:

VAR valText1 = "Text1"
VAR valText12 = "Text2"
VAR subt =
    CALCULATE (
        CALCULATE (
            SUM ( 'Table'[Sum] ),
            FILTER (
                'Table',
                'Table'[Type1] IN { 0 }
                    && NOT 'Table'[Type2] = 2
                    && NOT 'Table'[Code] IN { valText1, valText12 }
            )
        ),
        FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
    )
        - CALCULATE (
            CALCULATE (
                SUM ( 'Table'[Sum] ),
                FILTER (
                    'Table',
                    'Table'[Type1] IN { 0 }
                        && 'Table'[Type2] = 2
                        && NOT 'Table'[Code] IN { valText1, valText12 }
                )
            ),
            FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
        )
        - CALCULATE (
            CALCULATE (
                SUM ( 'Table'[Sum] ),
                FILTER (
                    'Table',
                    'Table'[Type1] IN { 0 }
                        && 'Table'[Code] IN { valText1, valText12 }
                        && 'Table'[Sign] > 0
                )
            ),
            FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
        )
        - CALCULATE (
            CALCULATE (
                SUM ( 'Table'[Sum] ),
                FILTER (
                    'Table',
                    'Table'[Type1] IN { 0 }
                        && 'Table'[Code] IN { valText1, valText12 }
                        && 'Table'[Sign] < 0
                )
            ),
            FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
        )
        + - CALCULATE (
            CALCULATE (
                SUM ( 'Table'[Sum] ),
                FILTER ( 'Table', 'Table'[Type1] IN { 2 } )
            ),
            FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
        )
RETURN
    SWITCH(TRUE(),
        "505s" in distinct ( 'Table_2'[Column1] ) ,
            - subt,
        "948r" in distinct ( 'Table_2'[Column1] ),
            subt
    )
2 REPLIES 2
AntrikshSharma
Community Champion
Community Champion

Prueba esto:

col =
VAR valText1 = "Text1"
VAR valText12 = "Text2"
VAR ListOfDate =
    FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
VAR F =
    FILTER (
        'Table',
        'Table'[Type1] IN { 0 }
            && NOT 'Table'[Code] IN { valText1, valText12 }
    )
VAR subt1 =
    CALCULATE (
        SUM ( 'Table'[Sum] ),
        F,
        KEEPFILTERS ( 'Table'[Type2] <> 2 ),
        ListOfDate
    )
VAR Subt2 =
    CALCULATE (
        SUM ( 'Table'[Sum] ),
        F,
        KEEPFILTERS ( 'Table'[Type2] = 2 ),
        ListOfDate
    )
VAR Subt3 =
    CALCULATE (
        SUM ( 'Table'[Sum] ),
        F,
        KEEPFILTERS ( 'Table'[Sign] > 0 ),
        ListOfDate
    )
VAR Subt4 =
    CALCULATE (
        SUM ( 'Table'[Sum] ),
        F,
        KEEPFILTERS ( 'Table'[Sign] < 0 ),
        ListOfDate
    )
VAR Subt5 =
    CALCULATE (
        SUM ( 'Table'[Sum] ),
        FILTER ( 'Table', 'Table'[Type1] IN { 2 } ),
        ListOfDate
    )
VAR Result = subt1 - Subt2 - Subt3 - Subt4 - Subt5
RETURN
    SWITCH (
        TRUE (),
        "505s" IN DISTINCT ( 'Table_2'[Column1] ), - Result,
        "948r" IN DISTINCT ( 'Table_2'[Column1] ), Result
    )
amitchandak
Super User
Super User

@Analitika ,¿Puede compartir datos de ejemplo y salida de ejemplo en formato de tabla y lógica de fórmula.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.