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

calculated column

Hi All, 

 

Hope everyone is doing good.

I need to write a calculated column which will give us the detail either the employee is working in samedept or differentdept.

below is the dataset

Employee IDDepartment 
E1101
E1102
E1103
E2101
E2102
E2201
E3201
E3202

As Employee E1 is working all the departments starting with 1 so it is marked as SameDept. Same goes for E3 employee as he is working in department starting with 2.

Whereas Employee E2 is working in department satrting with 1 and 2 so they need to be marked as DifferentDept.

Can you please help me on the same!!!!

5 REPLIES 5
niteshtrehan89
Helper III
Helper III

Hi @Fowmy 

Thanks for the solution. The data is around 1 lakh rows and still some of the records are not running properly. Needs a little tweak on the same. for the marked data it is not running properly. 

niteshtrehan89_1-1623047354378.png

 

 

 

 

 

@niteshtrehan89 

There was no mention about Department Status, I believe you need to check based on the employee id and the department status, please use the following modified code:

Dep Status =
VAR __emp = Table15[Employee ID],
VAR __status = Table15[Dep_Status]
VAR __dep =
    LEFT ( Table15[Department ], 1 )
RETURN
    IF (
        SUMX (
            FILTER ( Table15, Table15[Employee ID] = __emp && Table15[Dep_Status] = __status ),
            INT ( LEFT ( Table15[Department ], 1 ) <> __dep )
        ) = 0,
        "Same Department",
        "Different Department"
    )

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi @Fowmy 

Still not working. Infact the slicer department status is nothing but the same department and different department.

Same department= intercompany 

Different department= Non-intercompany

 

Hi. @niteshtrehan89 

Can you show your current adjusted code formula?

 

Best Regards,
Community Support Team _ Eason

Fowmy
Super User
Super User

@niteshtrehan89 

Add the following column to your table:

Dep Status = 
var __emp = Table15[Employee ID] return
var __dep = LEFT(Table15[Department ],1)

return
IF(
    SUMX( 
        FILTER(Table15, Table15[Employee ID] = __emp),
        int(LEFT(Table15[Department ],1) <> __dep)
    ) = 0,
    "Same Department",
    "Different Department"
) 

Fowmy_0-1622814548580.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.