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
Jaweed
Helper III
Helper III

how to add a new column with a value based on a column in a table

Hi to everybody

I have a table .   If the Service Code Column is like %RADMI%, the units  column is returned else 0 is returned. In below example only Code 1,2,3,8 will return the units in a calculated colmn 

 

 

Code         ServiceCode        Units        Calculated Colunm ( I want this column with below values to be returned)

1                 RADMIN               3             3

2                 RSADMIN             2             2

3                 RTADMINR           1             1

5                  TMEBASE             4             0

6                  NONWrK              2            0

7                  HOLDAY               6             0

8                  RHADMINT          3             3

 

Can anyone help me. I appeciate

 

 

 

1 ACCEPTED SOLUTION

For R%ADMI% try

IF(AND(Left('TableName'[ServiceCode],1)="R", ContainsString('TableName'[ServiceCode],"ADMI")),'TableName'[Units],0)

View solution in original post

4 REPLIES 4
AnthonyGenovese
Resolver III
Resolver III

Try this. Change TableName to the name of your table. This should only work for a calculated column. You would need different dax if you want it as a measure.
IF(ContainsString('TableName'[ServiceCode],"RADMI"),'TableName'[Units],0)

 

 

Thank you. Unfortunately it does not work.  If you use the comparison "RADMI",  then row RSADMIN gets a value of 0.

We nee to have a combination R%ADMI%.  Can you assist. Thanks

 

For R%ADMI% try

IF(AND(Left('TableName'[ServiceCode],1)="R", ContainsString('TableName'[ServiceCode],"ADMI")),'TableName'[Units],0)

Thank you so much Anthony. It works beautifully well.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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