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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

adding custom column by comparing data 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-2019      1
01-01-202031-01-2020      2
01-02-202029-02-2020      3
01-03-202031-03-2020      4
01-04-202030-04-2020      5
01-05-202031-05-2020      6

 

And the result table should be:

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

 

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.

8 REPLIES 8
amitchandak
Super User
Super User

@Anonymous , A new column like this in first table

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

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].

parry2k
Super User
Super User

@Anonymous I think you have a similar post, anyhow add the following column, change column and table name as per your model.

 

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

 

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!

 



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.

Anonymous
Not applicable

Thanks parry2k for response, I faced some issue with my old post while adding tables so created the new post.

 

I'm new to PowerBI. So, can you please explain a little bit where I need to add this formula? and why we are using MAX function here? I need to pull only the Iteration Number based on the creation date.

@Anonymous go to your task table, and in the menu, select add a new column, max is used to get maximum iteration number if it found two records, try this column and then let me know for any issue.

 

image.png

 

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!



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.

Anonymous
Not applicable

@parry2k I tried that but getting the below error.

 

DAX comparison operations do not support comparing values of type Date with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

 

image.png

@Anonymous can you make sure created date, start date, and end date is of data type, as you can clearly see in the error, one or more columns are not of the same data type.

 

I would recommend you take a guided learning course on Power BI to understand the basics.



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.

Anonymous
Not applicable

Sorry, @parry2k. I have changed the data type of Created Date, Start Date, and End Date to Date but I didn't refresh the table. After refreshing the table I didn't see any error in the formula. anyhow the data has not populated in the column.

 

Can you provide me the link where i can refer the formulas we can use?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.