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

Instert Row based on Condition

I have two tables that are tied by COID.  I have a list of Vacant posistions per COID and i need to add this row to the table that has the employees.

 

Table 1 Vacant Posistion:

Vacant COID Facility Change Vacancy Date DFM Start Date

 

Table 2 Employees:

Division COID Facility Employee Name Job Desc Pay
7 REPLIES 7
parry2k
Super User
Super User

@ghe7549 can you provide sample data and expected output.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k the second table below and highlighted green is what i need to add into table 1

 
Division COID Facility Employee Name Job Description Yearly Pay
SC DIVISION 12345 Harbor Town Tom Thomas Supv Fac Mgmt/Safety/Sec $57,138
SC DIVISION 12345 Harbor Town Brad Sellers Coordinator Support Svcs (CW) $52,000
SC DIVISION 12345 Harbor Town Morgan Evans Engineering Craft Worker $44,554
SC DIVISION 12345 Harbor Town Sam Smith Engineering Tech Specialist $44,138
SC DIVISION 12345 Harbor Town Vacant Dir Fac Mgmt/Safety/Sec xxxxxx
           
Vacant COID Facility Change Vacancy Date DFM Start Date
Vacant 12345 Harbor Town Left HCA 6/14/2019 12/20/18
Vacant 54635 Tri County Left HCA 4/9/2018 9/17/18
Vacant 22448 Macon Left HCA 4/20/2020 7/2/18
Vacant 34854 Table Top Left HCA 3/20/2020  

@ghe7549 how the table 1 columns are mapped to table 2, you can use UNION DAX function or you can append queries in Power Query

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k they are mapped using COID.  I feel that i am going to need to do a Power Query but not sure the best way to go about it.

What is COID? To add records from one table to another, use Table.Combine(), which is the APPEND menu item on the Home ribbon.

 

Otherwise, I'll need a few more specifics about the goal and what you are using.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

@edhans I am trying to add a rows to the employee table when there is a vacanies in table 2.

 

COID is what they both are tied to.

Ok. I'm not sure exactly what you mean by "Add" as adding is appending the data, and for the most part those do not have the same columns. However....

 

In table 2 I used the following Table.SelectRows logic:

= Table.SelectRows(#"Filtered Rows", each List.Contains(#"Table 1"[Facility], [Facility]))

The first part of List.Contains() is a list of the values in the [Facility] column. The 2nd part is the [Facility] field in table 2. I had manually filtered out any Vacancy dates with null.

 

I then created a new table that combined table 1, and the filtered version of table 2. You cannot append table 2 directly to table 1 as that will create a circular reference.

 

So I get this table, which looks strange because the columns aren't the same.

2020-05-19 12_56_01-20200519 - Select Rows based on List - Power Query Editor.png

See the PBIX file here.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.