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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
J_o_n_a_s
Helper I
Helper I

Something more practical than an IF Statement

Hi everyone, 

 

So i need to come up with a solution for when an employee changes department. The work hours of this employee from a certain date onwards have to be saved under the new department without affecting previous work hours. 

 

As a solution to this I came up with the idea of creating a new employee name (Jonas2) from the date that this employee changes department. In that case Jonas2 will be saved under department B and all his work hours will be saved under there too (while the old work hours of Jonas will remain under department A) . So this is what I came up with:

 

Jonas 2.PNG

 

 

 

 

Is there a smoother way of doing this please, since this will get quite complicated once it needs to be done for say 10 employees. 

 

Thanks for your help

Jonas

1 ACCEPTED SOLUTION

Hi @J_o_n_a_s ,

If different employees change department on different dates, I think it is necessary to compare date for each employee but you can try to optimize the formula, for example, using switch() function, using variables, like this:

 

Column =
VAR date1 =
    DATE ( 2020, 12, 31 )
VAR date2 =
    DATE ( 2020, 5, 8 )
VAR new = [Employee] & 2
RETURN
    SWITCH (
        [Employee],
        "Jonas", IF ( [Date] > date1, new, [Employee] ),
        "A",
            IF ( [Date] > date2, new & 2, [Employee] )
    )

 

em.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-yingjl
Community Support
Community Support

Hi @J_o_n_a_s ,

You need not to write if statements for each employees, just distinguish it by [Date], create column like this:

Column =
IF ( 'Table'[Date] > DATE ( 2020, 12, 31 ), [Employee] & "2", [Employee] )

employee.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

But what if different employees change department on different dates?

Hi @J_o_n_a_s ,

If different employees change department on different dates, I think it is necessary to compare date for each employee but you can try to optimize the formula, for example, using switch() function, using variables, like this:

 

Column =
VAR date1 =
    DATE ( 2020, 12, 31 )
VAR date2 =
    DATE ( 2020, 5, 8 )
VAR new = [Employee] & 2
RETURN
    SWITCH (
        [Employee],
        "Jonas", IF ( [Date] > date1, new, [Employee] ),
        "A",
            IF ( [Date] > date2, new & 2, [Employee] )
    )

 

em.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

VijayP
Super User
Super User

@J_o_n_a_s 

Tyring to understand the final objective .Should you create the data in a column only? What do you want to achieve as report , can you please share that as a snapshot?




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Yeah preferably in a column.

 

Basically the same result as what I got but in a more practical way for when more employees change department on different dates. I need to do this for past data as well so there will be several department changes. 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.