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
Milozebre
Helper V
Helper V

If contains function with a filter

Dear community, 

 

I need your help.

I would like to filter my measure with 2 criteria

First on the service which must always be "Contrat Assistance G" and on the category which must start with "APPRO" I know how to do it with filters on the element but I would like to make a measurement of it.

 

Test  =Calculate(distinctcount('dossiers') .... 

Here are the values for the columns

test.png

Thank you 

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Milozebre,

 

Assuming that your columns always start with the values you said then use this expression:

 

Count dossier =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Dossier] );
    LEFT ( 'Table'[Service]; 20 ) = "Contrat Assistance G";
    LEFT ( 'Table'[Categorie]; 5 ) = "APPRO"
)

If the columns don't start by that text but need to have that text within the column try this one:

 

Count dossier =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Dossier] );
    FIND ( "Contrat Assistance G"; 'Table'[Service]; 1; 0 ) > 0;
    FIND ( "APPRO"; 'Table'[Categorie]; 1; 0 ) > 0
)

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Milozebre,

 

Assuming that your columns always start with the values you said then use this expression:

 

Count dossier =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Dossier] );
    LEFT ( 'Table'[Service]; 20 ) = "Contrat Assistance G";
    LEFT ( 'Table'[Categorie]; 5 ) = "APPRO"
)

If the columns don't start by that text but need to have that text within the column try this one:

 

Count dossier =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Dossier] );
    FIND ( "Contrat Assistance G"; 'Table'[Service]; 1; 0 ) > 0;
    FIND ( "APPRO"; 'Table'[Categorie]; 1; 0 ) > 0
)

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Good morning MFelix, 

 

Its working.

 

Thnak you very much

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.