cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
essakkiappan
Helper I
Helper I

add custom column by comparing values in another table

Hi All,

 

I have two tables(A, B). 

Table A

Task idTitleCreated Date
1Title 113-05-2020
2Title 210-02-2020
3Title 323-03-2020
4Title 413-12-2019
5Title 510-04-2020

 

Table B:

Start DateEnd dateIteration Number
01-12-201931-12-20191
01-01-202031-01-20202
01-02-202029-02-20203
01-03-202031-03-20204
01-04-202030-04-20205
01-05-202031-05-20206

 

And the result table should be:

Task idTitleCreated DateIteration Number
1Title 113-05-20206
2Title 210-02-20203
3Title 323-03-20204
4Title 413-12-20191
5Title 510-04-20205

 

I want to add a column into table A which should be Iteration Number by comparing Created Date in between Start Date and End date.

 

I tried by merging two tables, appending it, adding a conditional column, custom column but nothing worked as expected.

 

I need a suggestion on how to handle this.

Thanks in advance.

1 ACCEPTED SOLUTION
amitchandak
Super User IV
Super User IV

@essakkiappan , new column in table A. Add conditions if needed

 

New column in Table A = minx(filter(TableB, TableB[StartDate]<= TableA[Created date] && TableB[End Date]>= TableA[Created date]),TableB[Iteration Number])



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

8 REPLIES 8
amitchandak
Super User IV
Super User IV

@essakkiappan , new column in table A. Add conditions if needed

 

New column in Table A = minx(filter(TableB, TableB[StartDate]<= TableA[Created date] && TableB[End Date]>= TableA[Created date]),TableB[Iteration Number])



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

Thanks @amitchandak for the response. I'm new to PowerBI. When I try to add the formula you gave in the Custom Column window, I'm not getting the Table B column[StartDate/EndDate].

 

Any idea?

@essakkiappan , Are you doing it in power query/edit query mode or new column in data mode.

Column name you can let power BI auto-suggest, keep on typing formula



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

@amitchandak I'm doing it in power query editor mode. I'm not getting the power BI suggestion for Table B column name. and I get the Token Literal Expected error when I add the column name manually.

 

image.png

@essakkiappan, I suggested a Dax column, So if this can help in case of power Query

https://radacad.com/append-vs-merge-in-power-bi-and-power-query



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Thanks, @amitchandak I have tried with merge and append but that's not solving my purpose. 

 

I'm checking how to add Dax column. will try with your solution once I know how to add Dax column.

 

Thanks!!

@essakkiappan did you tested the expression I provided, as mentioned, make sure change table and column name as per your model, we have used dummy table and column name to provide the solution, you have to change it as per your pbix.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!






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
Super User III
Super User III

@essakkiappan add the following column in your Task table

 

Iteration = 
VAR __createdDate = Tasks[Created Date]
RETURN
CALCULATE ( MAX ( Iteration[Iternation] ), __createdDate >= Iteration[Start], __createdDate <= Iteration[End] )

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!






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.





Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

html:
Carousel MBAS ARun Part 1 768x460

MBAS 2021

Join Arun Ulagaratchagan and the Power BI team at MBAS! #MSBizAppsSummit #CommunityRocks

April Update

Check it Out!

Click here to read more about the April 2021 Updates!

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!