Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
Solved! Go to Solution.
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
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!
Hi @m4d
use this code to add a new column with DAX:
New Column =
IF (
CONTAINSSTRING ( 'Table'[Activity Type], "Tutorial" ),
'Table'[Hours],
BLANK ()
)
Output:
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.
Hi,
please check the below. It is for creating a calculated column ( not a calculated measure).
User | Count |
---|---|
23 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
12 | |
11 | |
7 | |
6 |