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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mork
Helper V
Helper V

Problem with conditional column (M)

Hello all,

 

I have a table with timesheet data that my resources fill.

In this table I have a column called actual work which shows the hours spent by my resources and another column called worktype that shows the type of work (e.g. ProjectWork, Vacation, Skillsdevelopement etc.).

 

I'm trying to create a conditional column that will be exactly the same with the actual work column but where worktype is vacation the actual work will be zero.

example table:

 

 

ActualWork        WorkType         ActualWorkNoVac

      3                     Project                        3

      4                      Internal                      4

      5                     project                        5

       8                     Vacation                     0

       2              SkillsDevelopement          2

 

etc.

 

I have created the following formula in M

 

#"Added Conditional Column" = Table.AddColumn(#"PreviousStep", "ActualWorkNoVac", if each [WorkType] <> "Vacation" then [Actual Work] else "0")

 

 

This mostly work but for some reason for a few rows (like 5-6 rows) the actualWorkNoVac is not zero but it's the same as actual work even though WorkType is vacation. Is there something wrong with my M formula?

1 ACCEPTED SOLUTION
mork
Helper V
Helper V

Nevermind I found the error. In my formula I'm actually comparing with the taskID and not with the actual worktype which is text. And for some reason for these few entries the taskId provided by the project server is not the same with the taskId I use in my formula. 

So I'll just change the formula and just compare with the work type.

View solution in original post

1 REPLY 1
mork
Helper V
Helper V

Nevermind I found the error. In my formula I'm actually comparing with the taskID and not with the actual worktype which is text. And for some reason for these few entries the taskId provided by the project server is not the same with the taskId I use in my formula. 

So I'll just change the formula and just compare with the work type.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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