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

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

Reply
Anonymous
Not applicable

Merge queries with similar dates

Hi Community, 

 

I have a problem with this as in, I don't know what's the easiest way to make this happen. Here it is the scenario:

 

In Table A i have the following data

 

origDestTravl FromTravel ToExpiry Date
XXXYYY1/11/201815/12/201810/07/2018
ABCCDE20/01/20195/04/201920/08/2018
ZZZAAA30/04/20196/01/201910/05/2018

 

And in Table B this one:

 

Travel FromTravel ToIndex
1/11/201815/12/2018TP1
9/01/20195/04/2019TP2
29/04/20196/01/2019TP3

 

 

I have to merge the index into Table A if travel from and travel to are similar. The travel month and year shall be the same but the day of the month can be flexible. 

 

I thought that merging queries would be the easiest way but it didn't really work out

 

 

6 REPLIES 6
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

"I have to merge the index into Table A if travel from and travel to are similar."

How should we understand “similar”? To reference to the "Index" column of Table B in Table A, you should provide a specific rule.

 

For example, if there existing some records in Table B like below:

19/01/2019 5/04/2019 TP4
21/01/2019 5/04/2019 TP5

 

Which "Index" should be added to below row in Table A?

ABC CDE 20/01/2019 5/04/2019 20/08/2018

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Yuliana, 

 

sorry for being inaccurate. What i mean is that the column index (so TP1,2,3) should be merged into the Table a IF Travl Form and Travel To are similar (say, there is a difference of +/-5 days for both).

 

I can make specific, in other words to merge only if these fields are matching but in this model a bit of flexibility would be great. 

 

Hope i clarified myself.

 

cheers

Alberto

Anonymous
Not applicable

Hi @Anonymous,

 

I have just extracted month and year from your both table column( Travel To) and just joined both tables.

Assuming that Month& Year of Travelto will be same for the both table. Then Just created a new column with RELATED Dax.

For your refernce i am attaching PBIX File here. Kindly see and revert me if any concern.

 

Best Regards,

Ravi

Anonymous
Not applicable

Hi Ravi, 

 

thank you for your feedback. I thought to do something like this, basically considering the month only despite the day of the month. Could be a solution. ATM i merged 2 query to 2 query as there are more fields to match: I am sure there is a better way to do this but at the moment this is what i came up with:

 

Again we have 2 tables:

Table A

 

              
OrigDestcxrSale EndTravel fromTravel toSale Range IndexSale End Index      
XXXYYYAB10/05/20181/01/201910/02/2019TP1SP1      
XXXYYYAB10/06/20181/01/201912/02/2019TP1SP1      
XXXYYYAB10/06/20181/03/201912/04/2019TP2SP2      
              
 TAble B             
OrigDestcxrSale EndTravel fromTravel toSale Range IndexSale End Index      
XXXYYYBC8/05/20181/01/201911/02/2019TP1SP1      
XXXYYYBC8/05/20181/01/201912/02/2019TP1SP1      
XXXYYYBC10/06/20181/03/201912/04/2019TP2SP2      
              
 Merged: TABLE C             
              
OrigDestcxrSale EndTravel fromTravel toSale Range IndexSale End IndexcxrSale EndTravel fromTravel toSale Range Index
XXXYYYAB10/05/20181/01/201910/02/2019TP1SP1BC8/05/20181/01/201911/02/2019TP1SP1
XXXYYYAB10/06/20181/01/201912/02/2019TP1SP1BC8/05/20181/01/201912/02/2019TP1SP1
XXXYYYAB10/06/20181/03/201912/04/2019TP2SP2BC10/06/20181/03/201912/04/2019TP2SP2

 

This solution works theorethically but it's too strict (and complex) but the outcome that delivers is outstanding. 

Do you think i can modify my query in a way that only checks the month?

 

I'm trying to attach the .pbix file but I don't know how to do it

Anonymous
Not applicable

Hi @Anonymous,

 

Thank you for feedback.Smiley Happy

Though i am not getting your actual requirement as you mentioned above.

i can modify my query in a way that only checks the month?

If you are asking that only month basis then yes you can.

 

For Your Concern i have a question and some suggestion.

1. Why do you need this type of data. It can be handle in StarSchema( Fact and Dimension).

2. You can handle it in SQL Query if data is coming from database.

 

 

Best Regrads,

Ravi

 

 

Anonymous
Not applicable

Hi Ravi, 

 

"i can modify my query in a way that only checks the month?

If you are asking that only month basis then yes you can"

 

in other words: as you've done, you changed the format of travel date from/to to extract the month and year through a calculated column. At the moment my model merges the 2 tables at query level so they only match if those fields are consistent. 

So don't know how to set up the query to re-script in order to extract month/year  accordingly. But in any case the month only could be too generic because if there are many difference days between date from table A and B that may be meaningless. 

 

 

Why do you need this type of data. It can be handle in StarSchema( Fact and Dimension)

Well this is part of a business process automation process and this is what the company provides. Don't know StarSchema

 

. You can handle it in SQL Query if data is coming from database.

It comes from a shared .xls file from a share point location. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.