Forum Discussion

brockry1's avatar
brockry1
Helper II
1 year ago
Solved

Contains vs Equals

I have this measure to bring back the toatal traings from the subject column in the events and Tasks table.  I want it to show "Contains" vs equals at the end but im getting an error when trying.  How do I adjsut to get contains  trainings in the subject column? 
 
# of completed events_Trainings = CALCULATE(DISTINCTCOUNT('Event & Task'[ID]),'Event & Task'[Status (Consolidated)]="Completed", 'Event & Task'[Subject] = "Training")
  • Hello brockry1 

    You can use the following DAX formula instead if you want to determine whether the Subject column contains the "Training" string or not:

     

     

    # of completed events_Trainings =
    CALCULATE (
        DISTINCTCOUNT ( 'Event & Task'[ID] ),
        'Event & Task'[Status (Consolidated)] = "Completed",
        CONTAINSSTRING ( 'Event & Task'[Subject], "Training" ) = TRUE
    )
    

     

     

    The CONTAINSSTRING() function is case-insensitive. However, if you require a strictly case-sensitive check, use CONTAINSSTRINGEXACT() instead.

     

    You can learn more about these functions here:

    I have created small dataset of only 10 rows verify the, and here is the screenshot of it

    I am also attaching the sample Power BI file for your reference.

     

    Best Regards,
    Udit

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudo πŸ‘

    πŸš€ Let's Connect: LinkedIn || YouTube || Medium || GitHub
    ✨ Visit My Linktree: LinkTree

    Proud to be a Super User

1 Reply

  • Hello brockry1 

    You can use the following DAX formula instead if you want to determine whether the Subject column contains the "Training" string or not:

     

     

    # of completed events_Trainings =
    CALCULATE (
        DISTINCTCOUNT ( 'Event & Task'[ID] ),
        'Event & Task'[Status (Consolidated)] = "Completed",
        CONTAINSSTRING ( 'Event & Task'[Subject], "Training" ) = TRUE
    )
    

     

     

    The CONTAINSSTRING() function is case-insensitive. However, if you require a strictly case-sensitive check, use CONTAINSSTRINGEXACT() instead.

     

    You can learn more about these functions here:

    I have created small dataset of only 10 rows verify the, and here is the screenshot of it

    I am also attaching the sample Power BI file for your reference.

     

    Best Regards,
    Udit

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudo πŸ‘

    πŸš€ Let's Connect: LinkedIn || YouTube || Medium || GitHub
    ✨ Visit My Linktree: LinkTree

    Proud to be a Super User