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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Loic_Pedro_Hans
Regular Visitor

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 ?
pwb1.png
Thanks a lot
2 REPLIES 2
Loic_Pedro_Hans
Regular Visitor

Thanks Rongtie,

I Try to do a best explanation for my problem.

The problem is about CALCULATE.

 

First Syntax

Loic_Pedro_Hans_0-1692365881316.png

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

Loic_Pedro_Hans_1-1692366002526.png

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

Why ??

Loic_Pedro_Hans_2-1692366046914.pngLoic_Pedro_Hans_3-1692366060734.png

Thank a lot.

 

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.

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!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.