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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
AsmaBenhassine9
Frequent Visitor

Unable to join two tables based on condition Power Query

I have Table A and Table B  and i need to get the Tranche_ID from Table B.

Table A

 

ID_Client

ID_Collaborateur

Nombre_Dossiers

1

2

6

1

3

4

2

3

2

Table B

 

ID_Tranche

Min_Tranche

Max_Tranche

1

1

2

2

3

5

3

610

 

Condition : if Nombre_dossiesr > Min_tranche and Nombre_dossiers < Max_Tranche then  => Recover the ID_TRANCHE

 

Result 

 

ID_Client

ID_collaborateur

ID_Tranche

Nombre_dossiers

1

2

3

6

1

3

2

4

2

3

1

2

 

i create a custom column in power query :


Table.SelectRows(TableB, (TableB) => TableB[Min_Tranche]<=[Nombre_dossiers] and TableB[Max_Tranche] >= [Nombre_dossiers])[ID_Tranche]{0}

 

but i have this error 

error.PNG

 

Any help please ? !

 

 

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Salut, @AsmaBenhassine9 , ta formule marche bien de mon côté 😂; la formule complete est comme ça

 

 

#"Colonne Ajoutée" = Table.AddColumn(#"Renamed Columns", "ID_Tranche", each Table.SelectRows(TableB, (t) => t[Min_Tranche]<=[Nombre_dossiers] and t[Max_Tranche] >= [Nombre_dossiers])[ID_Tranche]{0})

 

 

Screenshot 2020-11-01 034654.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
AsmaBenhassine9
Frequent Visitor

it works very well. Thank you 🙂

CNENFRNL
Community Champion
Community Champion

Salut, @AsmaBenhassine9 , ta formule marche bien de mon côté 😂; la formule complete est comme ça

 

 

#"Colonne Ajoutée" = Table.AddColumn(#"Renamed Columns", "ID_Tranche", each Table.SelectRows(TableB, (t) => t[Min_Tranche]<=[Nombre_dossiers] and t[Max_Tranche] >= [Nombre_dossiers])[ID_Tranche]{0})

 

 

Screenshot 2020-11-01 034654.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

shaowu459
Resolver II
Resolver II

Hi @AsmaBenhassine9, try below code:

 

 

let
    tblA = Excel.CurrentWorkbook(){[Name="TableA"]}[Content],
    tblB = Excel.CurrentWorkbook(){[Name="TableB"]}[Content],
    res = Table.AddColumn(tblA," ID_Tranche",each Table.SelectRows(tblB,(x)=>x[Min_Tranche]<=[Nombre_Dossiers] and x[Max_Tranche]>=[Nombre_Dossiers]){0}[ID_Tranche])
in
    res

 

 1.png

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.