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
don_writer
Helper II
Helper II

DAX Pulling info from another table

I have two tables. srcActive and srcOpenPositions. 

 

srcActive Table

MonthYear                                     EEID      auto_req_ID    Hire_Date                         Employee_Group

Sunday, January 01, 201722222Z1Friday, January 20, 2017Hourly
Sunday, January 01, 201733333Y1Saturday, January 14, 2017Exempt
Wednesday, February 01, 201744444X1Friday, February 10, 2017Non-Exempt
Monday, May 01, 201755555W1Friday, May 05, 2017Intern
Thursday, June 01, 201766666V1Thursday, June 01, 2017Exempt
Sunday, October 01, 201777777U1Tuesday, October 10, 2017Non-Exempt
Friday, December 01, 201788888T1Friday, December 01, 2017Intern
Monday, January 01, 201899999S1Tuesday, January 23, 2018Exempt
Sunday, April 01, 201812122R1Tuesday, April 17, 2018Non-Exempt
Tuesday, May 01, 201813133Q1Wednesday, May 30, 2018Intern
Sunday, July 01, 201814144P1Saturday, July 07, 2018Exempt
Sunday, July 01, 201815155O1Monday, July 09, 2018Non-Exempt
Wednesday, August 01, 201816166N1Wednesday, August 08, 2018Exempt

 

srcOpenPositions

MonthYear                              auto_req_ID    Employee_Group

   
Wednesday, February 01, 2017X1 
Monday, May 01, 2017W1 
Thursday, June 01, 2017V1 
Sunday, October 01, 2017U1 
Friday, December 01, 2017T1IN
Monday, January 01, 2018S1EX
Sunday, April 01, 2018R1NE
Tuesday, May 01, 2018Q1IN
Sunday, July 01, 2018P1EX
Sunday, July 01, 2018O1NE
Wednesday, August 01, 2018N1EX
Thursday, August 02, 2018M1NE
Wednesday, August 15, 2018L1IN
Saturday, September 01, 2018K1EX

 

What I want to do is create a coumn that changes pull Employee group into the Open Postions table via Auto_req_ID. The two tables have some overlap in Auto_Req_ID but not all. If it doesn't exist I'd like to convert the abbreviation in the OpenPositions Employee_Category to be spelled out like in the Active table. Here is the code I wrote but I am uncertain what I am doing wrong.

 

EmployeeCategory = SUMMARIZE(
    srcOpenPositions,
    srcOpenPositions[auto_req_id],
    srcOpenPositions[employee_category],
    "Employee_Subgroup",
    SWITCH( TRUE(),
            srcOpenPositions[employee_category]="EX","Exempt",
                srcOpenPositions[employee_category]="NE","Non-Exempt",
                srcOpenPositions[employee_category]="PX","Project Employee Exempt",
                srcOpenPositions[employee_category]="PH","Project Employee Hourly",
                srcOpenPositions[employee_category]="IN","Intern",
                srcOpenPositions[employee_category]="HR","Hourly",
                srcOpenPositions[employee_category]="",LOOKUPVALUE(srcActive[employee_group],srcActive[Auto_Req_ID],srcOpenPositions[auto_req_id])
         ))

 

Your help is appreciated,

~Don

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@don_writer,

Your code works well and returns correct result based on the sample data. What issue do you get?

EmployeeCategory = SUMMARIZE(
    srcOpenPositions,
    srcOpenPositions[MonthYear],
    srcOpenPositions[auto_req_id],
    srcOpenPositions[employee_category],
    "Employee_Subgroup",
    SWITCH( TRUE(),
            srcOpenPositions[employee_category]="EX","Exempt",
                srcOpenPositions[employee_category]="NE","Non-Exempt",
                srcOpenPositions[employee_category]="PX","Project Employee Exempt",
                srcOpenPositions[employee_category]="PH","Project Employee Hourly",
                srcOpenPositions[employee_category]="IN","Intern",
                srcOpenPositions[employee_category]="HR","Hourly",
                srcOpenPositions[employee_category]="",LOOKUPVALUE(srcActive[employee_group],srcActive[Auto_Req_ID],srcOpenPositions[auto_req_id])
         ))


1.PNG


Instead of creating a new table, you can directly create a new column in the srcOpenPositions table using DAX below. For more details, please check attached PBIX file.

Column = IF(srcOpenPositions[employee_category]="",LOOKUPVALUE(srcActive[employee_group],srcActive[Auto_Req_ID],srcOpenPositions[auto_req_id]),SWITCH(TRUE(),
            srcOpenPositions[employee_category]="EX","Exempt",
                srcOpenPositions[employee_category]="NE","Non-Exempt",
                srcOpenPositions[employee_category]="PX","Project Employee Exempt",
                srcOpenPositions[employee_category]="PH","Project Employee Hourly",
                srcOpenPositions[employee_category]="IN","Intern",
                srcOpenPositions[employee_category]="HR","Hourly"))



2.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
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

4 REPLIES 4
v-yuezhe-msft
Employee
Employee

@don_writer,

Your code works well and returns correct result based on the sample data. What issue do you get?

EmployeeCategory = SUMMARIZE(
    srcOpenPositions,
    srcOpenPositions[MonthYear],
    srcOpenPositions[auto_req_id],
    srcOpenPositions[employee_category],
    "Employee_Subgroup",
    SWITCH( TRUE(),
            srcOpenPositions[employee_category]="EX","Exempt",
                srcOpenPositions[employee_category]="NE","Non-Exempt",
                srcOpenPositions[employee_category]="PX","Project Employee Exempt",
                srcOpenPositions[employee_category]="PH","Project Employee Hourly",
                srcOpenPositions[employee_category]="IN","Intern",
                srcOpenPositions[employee_category]="HR","Hourly",
                srcOpenPositions[employee_category]="",LOOKUPVALUE(srcActive[employee_group],srcActive[Auto_Req_ID],srcOpenPositions[auto_req_id])
         ))


1.PNG


Instead of creating a new table, you can directly create a new column in the srcOpenPositions table using DAX below. For more details, please check attached PBIX file.

Column = IF(srcOpenPositions[employee_category]="",LOOKUPVALUE(srcActive[employee_group],srcActive[Auto_Req_ID],srcOpenPositions[auto_req_id]),SWITCH(TRUE(),
            srcOpenPositions[employee_category]="EX","Exempt",
                srcOpenPositions[employee_category]="NE","Non-Exempt",
                srcOpenPositions[employee_category]="PX","Project Employee Exempt",
                srcOpenPositions[employee_category]="PH","Project Employee Hourly",
                srcOpenPositions[employee_category]="IN","Intern",
                srcOpenPositions[employee_category]="HR","Hourly"))



2.PNG

Regards,
Lydia

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

@v-yuezhe-msft

Hi Lydia,

 

I'm not certain why but in my real dataset I get the error:

"A table of multiple values was supplied where a single value was expected."

For both the table and column versions.

 

Yes the tables are bigger but otherwise I can't see any significant differences other than more fields. 😞

 

Thank you for your input,

~Don

An update:
I realized that in the actual data there are multiple instances of each auto_req_id for that lookup value. I will figure out how to fix that and get back.

 

Thanks,

~Don

@don_writer,

For the first DAX, please click "New Table" to apply formula. For the second DAX, please right-click you table and select "New Column" then apply the formula.

Regards,
Lydia

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

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.