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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply

This filter clause do as its own mind

Hello
I can't understand why this filter returns information about agency of "Paris" and "Aix" when I'm only asking for "Niort".

CALCULATE(AVERAGE('Affectation Collaborateurs'[TAUX HSITE]);FILTER('Affectation Collaborateurs';'Affectation Collaborateurs'[AGENCE] ="Niort" ))

 

Sans-titre-1.jpg

 Sans-titre-2.jpg

 

Can somebody explain where I'm wrong?

1 ACCEPTED SOLUTION

Hi,

So it seems that you solved this problem, right? If so and if you'd like to, you could mark corresponding post as answer or share your solutions. That way, people who in this forum and have similar issue will benefit from it.

Best Regards,
Zoe Zhi

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

View solution in original post

12 REPLIES 12
SivaMani
Resident Rockstar
Resident Rockstar

@PatrickByGecko ,

 

Did you try it as a calculated Measure?

I just tried it gives this formula =>

Moyenne de TAUX HSITE pour Niort =
CALCULATE(
    AVERAGE('Affectation Collaborateurs'[TAUX HSITE]);
    'Affectation Collaborateurs'[AGENCE] IN { "Niort" }
)
And it returns always for Aix and Paris too...

Hi PatrickByGecko,

You need to use measure instead of calculated column(which will apply result to all table), you could refer to my sample for details.

Best Regards,
Zoe Zhi

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

I'm sorry but it is a measure (have a look underneath) .

Could you give an example of syntax?

AEffacer.jpg

 

@PatrickByGecko,

 

You're almost there.

 

Here is the example code,

Average Test = CALCULATE(AVERAGE(Orders[Quantity]), FILTER(Orders,Orders[Ship Mode] = "First Class") )

 
Please do give a try and let me know!

 

Well done Siva. That works.

But my results need more tuning because I need to calculate average for distinct values of an other columns. For instance in your example Destination;

 

Quantity                  Ship Mode                   Destination      Year

8                               First Class                    France              2019

3                               First Class                    Usa                   2019

10                             First Class                    France              2020

 

The Average we saw before will give  (10+3+8)/3 =7

The Average for distinct Destination will give ( (18/2=9) + 10 ) /2 = 8

How can I do that?

🙂

Sorry I did a mistake on what I mean =>

----------------------------

Quantity                  Ship Mode                   Destination      Year

8                               First Class                    France              2019

3                               First Class                    Usa                   2019

10                             First Class                    France              2020

 

The Average we saw before will give  (10+3+8)/3 =7

The Average for distinct Destination will give ( 18 + 3 ) /2 = 10,5

How can I do that?

----------

@PatrickByGecko,

 

Here you go,

DIVIDE(SUM(Orders[Quantity]), DISTINCTCOUNT(Orders[Destination ]))

 

Thanks

But it don't works with a filter =>

Moy Hors Site =
CALCULATE(
    DIVIDE (SUM(CollabAffectImmediat[TAUX HSITE])/DISTINCTCOUNT(CollabAffectImmediat[NOM]);
    FILTER(CollabAffectImmediat;CollabAffectImmediat[DATE DEBUT]<=today() && CollabAffectImmediat[DATE FIN]> TODAY() && CollabAffectImmediat[CODE PROJET]<> "GKOFORMA1" && CollabAffectImmediat[CODE PROJET]<>"GKOMAINT1"&& CollabAffectImmediat[CODE PROJET]<>"GKOAVENTE" )
))
I get this error => L'expression fait référence à plusieurs colonnes. Plusieurs colonnes ne peuvent pas être converties en une valeur scalaire.
Sans-titre-1.jpg

 

 

@PatrickByGecko,

 

Have you tried this?

Calculate(<exp>,

FILTER(CollabAffectImmediat;CollabAffectImmediat[DATE DEBUT]<=today() && CollabAffectImmediat[DATE FIN]> TODAY()) FILTER(CollabAffectImmediat;CollabAffectImmediat[CODE PROJET]<> "GKOFORMA1" && CollabAffectImmediat[CODE PROJET]<>"GKOMAINT1"&& CollabAffectImmediat[CODE PROJET]<>"GKOAVENTE" ))

Hello

I succeeded this way =>

 

Moy Hors Site =
DIVIDE (
Calculate (
SUM(CollabAffectImmediat[TAUX HSITE]);
    FILTER(CollabAffectImmediat;CollabAffectImmediat[DATE DEBUT]<=today() && CollabAffectImmediat[DATE FIN]> TODAY() )
);
CALCULATE(
DISTINCTCOUNT(CollabAffectImmediat[NOM]);
FILTER(CollabAffectImmediat;CollabAffectImmediat[DATE DEBUT]<=today() && CollabAffectImmediat[DATE FIN]> TODAY() )
)
)
 
 

Hi,

So it seems that you solved this problem, right? If so and if you'd like to, you could mark corresponding post as answer or share your solutions. That way, people who in this forum and have similar issue will benefit from it.

Best Regards,
Zoe Zhi

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.