Forum Discussion

Loic_Pedro_Hans's avatar
Loic_Pedro_Hans
Regular Visitor
3 years ago

Problem with CALCULATE, lost the filter context

Hi,
 
This formula is good :
Avg Delivery Days = 
AVERAGEX (
    FILTER (
        Delivery_Dte_Fioul_Particuliers,
        NOT (Delivery_Dte_Fioul_Particuliers[AGC_LIBC] IN {"x-VDSN","T-PSE Siège",""})
    ),
    Delivery_Dte_Fioul_Particuliers[DELIVERY DATE]
)
 
This formula using CALCULTATE don't work :
Avg Delivery DaysCalc = 
CALCULATE (
    AVERAGEX (
        Delivery_Dte_Fioul_Particuliers,
        Delivery_Dte_Fioul_Particuliers[DELIVERY DATE]
    ),
    Delivery_Dte_Fioul_Particuliers[AGC_LIBC] IN {"PACA","T-PSE Siège",""}
)
 
[U]Le résultat[/U] 
 
AGC_LIBC        Avg Delivery DaysCalc Avg Delivery Days
                     2,474247287
Brg Frnch Comte     2,474247287 4,190534486
Loire Auvergne      2,474247287 2,703824046
LVDR              2,474247287 3,133449115
Lyon PDA              2,474247287 3,675738426
PACA              2,474247287 2,489297886
Savoies              2,474247287 4,485062751
T-PSE Siège     2,474247287
x-VDSN             2,474247287
 
Why when using CALCULTATE, the filter context don't work, but only a global average ?
Thanks a lot

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Loic_Pedro_Hans ,

    Please have a try.

    measure =
    CALCULATE (
        AVERAGE ( Delivery_Dte_Fioul_Particuliers[DELIVERY DATE] ),
        FILTER (
            ALL ( Delivery_Dte_Fioul_Particuliers ),
            Delivery_Dte_Fioul_Particuliers[AGC_LIBC] IN { "PACA", "T-PSE Siège", "" }
        )
    )
    

     

    How to Get Your Question Answered Quickly 

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Rongtie

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Thanks Rongtie,

    I Try to do a best explanation for my problem.

    The problem is about CALCULATE.

     

    First Syntax

    With this syntax the row context can be apply normaly, a different value for every Agency.

    If I use another formula, the value is good (3,70 TOTAL), but there is no several values with the agency context

    Why ??

    Thank a lot.