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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
m4d
New Member

Help - SUMIF where text contains a specific word

Hi everyone, 

 

I've been researching this but I can't seem to find a solution. 

 

My dataset is like the below:

 

Activity Type       Hours     

Initial Tutorial       4

Initial Lecture       5

Repeat Tutorial     6

 

I want to create a new column that returns the hour value if the Activity Type column contains "Tutorial". If the row does not contain "tutorial" I want it to return a blank cell. I want this to evaluate row by row. There are many versions of the Activity Type that will be added on to this dataset and I can't create an exhaustive list. 

 

I don't use DAX often so feeling a bit stuck. Any help is greatly appreciated. 

 

 

 

 

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @m4d ,

 

You can try any of below code:-

Column =
IF (
    SEARCH ( "Tutorial", 'Table'[Activity Type], 1, 0 ),
    'Table'[Hours],
    BLANK ()
)

or

Column = 
IF (
    Find ( "Tutorial", 'Table'[Activity Type], 1, 0 ),
    'Table'[Hours],
    BLANK ()
)

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

5 REPLIES 5
Samarth_18
Community Champion
Community Champion

Hi @m4d ,

 

You can try any of below code:-

Column =
IF (
    SEARCH ( "Tutorial", 'Table'[Activity Type], 1, 0 ),
    'Table'[Hours],
    BLANK ()
)

or

Column = 
IF (
    Find ( "Tutorial", 'Table'[Activity Type], 1, 0 ),
    'Table'[Hours],
    BLANK ()
)

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

The first one worked perfectly - thank you very much!

VahidDM
Super User
Super User

Hi @m4d 

 

use this code to add a new column with DAX:

New Column =
IF (
    CONTAINSSTRING ( 'Table'[Activity Type], "Tutorial" ),
    'Table'[Hours],
    BLANK ()
)

 

Output:

 

VahidDM_0-1642742110918.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Thanks, unfortunately power pivot won't recognise CONTAINSSTRING. Is there a workaround or is it not possible in Excel? I have the latest 365 version.

Jihwan_Kim
Super User
Super User

Hi,

please check the below. It is for creating a calculated column ( not a calculated measure).

 

Picture1.png

 

Hours tutorial CC =
IF ( CONTAINSSTRING ( Data[Activity Type], "Tutorial" ), Data[Hours] )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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