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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
greg0307
Frequent Visitor

Multiple Filter context and date

Hi,

 

I'm having issue with filtering context and multiple date, below schema of database and DAX measure.

 

BP Ratio Clôturés dans les délais = 1 -
DIVIDE(
(CALCULATE(
DISTINCTCOUNT(CompteRendu[id_bp]),
CompteRendu[Retard]="Retard",ALL('Date'),CompteRendu[code_categorie]="P0") +
(CALCULATE(
DISTINCTCOUNT(CompteRendu[id_bp]),
CompteRendu[Retard]="Retard",CompteRendu[etat_bp]<>"CLO",ALL('Date'),CompteRendu[code_categorie]="P0") -
CALCULATE(
DISTINCTCOUNT(CompteRendu[id_bp]),
CompteRendu[Retard]="Retard",CompteRendu[etat_bp]<>"CLO",CompteRendu[code_categorie]="P0"))),
CALCULATE(
DISTINCTCOUNT(BP[id_bp]),BP[etat_bp]="CLO",REMOVEFILTERS(CompteRendu[Date Fin Réelle]),KEEPFILTERS('Date'[Date])))

greg0307_0-1618305614194.png

greg0307_1-1618305816608.png

 

 

Filter context must filter on "date fin réelle" table "Compte-Rendu" and "date début prévu" on "BP" for measure "BP Ratio Clôturés dans les délais".

Value on three table on left is ok, result of measure are wrong, after many days of trying to resolve this issue.

Thanks for your help

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@greg0307 

Perhaps try creating your inner calculations as discrete measures then using them in your final calculation.  This can help with trouble shooting the intermediate steps.

A = CALCULATE (
    DISTINCTCOUNT ( CompteRendu[id_bp] ),
    CompteRendu[Retard] = "Retard",
    ALL ( 'Date' ),
    CompteRendu[code_categorie] = "P0" )
B = CALCULATE (
    DISTINCTCOUNT ( CompteRendu[id_bp] ),
    CompteRendu[Retard] = "Retard",
    CompteRendu[etat_bp] <> "CLO",
    ALL ( 'Date' ),
    CompteRendu[code_categorie] = "P0" )
C = CALCULATE (
    DISTINCTCOUNT ( CompteRendu[id_bp] ),
    CompteRendu[Retard] = "Retard",
    CompteRendu[etat_bp] <> "CLO",
    CompteRendu[code_categorie] = "P0" )
D = CALCULATE (
    DISTINCTCOUNT ( BP[id_bp] ),
    BP[etat_bp] = "CLO",
    REMOVEFILTERS ( CompteRendu[Date Fin Réelle] ),
    KEEPFILTERS ( 'Date'[Date] ) )
BP Ratio Clôturés dans les délais =
1 - DIVIDE ( ( [A] + ( [B] - [C] ) ), [D] )

 

 

 

View solution in original post

4 REPLIES 4
v-janeyg-msft
Community Support
Community Support

Hi, @greg0307 

 

According to your description, the result of the measure is wrong,right? But you didn't provide the code for the measure. The contexts in the card and table are not the same, so you need to write the corresponding code. I think the code and screenshots you provided are not helpful in solving your problem.

If you hasn't resolved the issue, please share some sample fake data and your desired result like,and feel free to ask me.

 

Best Regards

Janey Guo

 

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

greg0307
Frequent Visitor

Hi, 

 

Already try this context filtering appying too.

 

jdbuchanan71
Super User
Super User

@greg0307 

Perhaps try creating your inner calculations as discrete measures then using them in your final calculation.  This can help with trouble shooting the intermediate steps.

A = CALCULATE (
    DISTINCTCOUNT ( CompteRendu[id_bp] ),
    CompteRendu[Retard] = "Retard",
    ALL ( 'Date' ),
    CompteRendu[code_categorie] = "P0" )
B = CALCULATE (
    DISTINCTCOUNT ( CompteRendu[id_bp] ),
    CompteRendu[Retard] = "Retard",
    CompteRendu[etat_bp] <> "CLO",
    ALL ( 'Date' ),
    CompteRendu[code_categorie] = "P0" )
C = CALCULATE (
    DISTINCTCOUNT ( CompteRendu[id_bp] ),
    CompteRendu[Retard] = "Retard",
    CompteRendu[etat_bp] <> "CLO",
    CompteRendu[code_categorie] = "P0" )
D = CALCULATE (
    DISTINCTCOUNT ( BP[id_bp] ),
    BP[etat_bp] = "CLO",
    REMOVEFILTERS ( CompteRendu[Date Fin Réelle] ),
    KEEPFILTERS ( 'Date'[Date] ) )
BP Ratio Clôturés dans les délais =
1 - DIVIDE ( ( [A] + ( [B] - [C] ) ), [D] )

 

 

 

It's ok, just don't forget to apply correct context filter on each measure (Date Slicer).

Thanks for you help, too many time spent for simply things 😞

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.