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
vishy86
Post Patron
Post Patron

JOIN to another table based on condition

Hi,

 

I have a dataset in Power BI with Policy Number, Flag and Program Code i.e. 3 separate columns.

 

There is another excel table with columns Flag, Policy No/Program Code and other attributes.

 

I need my current Power BI dataset to JOIN to this excel table based on a condition.

- If Flag is Y then join using Policy Number and Flag to return the other attributes.

- If Flag is N then join using Program Code and Flag to return the other attributes.

 

Is it possible to do this using one dataset itself so that eventually one report can cater to all instead of two separate reports.

 

Thanks,

Vishy

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @vishy86 ,

I'd like to suggest you enter to query edit and use 'unpivot columns' on attribute columns of these tables, then you can union two tables to one.

Unpivot columns (Power Query) 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft ,

 

Both the tables do not have the same number of columns hence I cannot do Union on the tables.

 

I tried splitting the table into 2 different tables one with Policy No and one with Program Code, not sure this is working correctly either.

 

Regards,

Vishy

Hi @vishy86 ,

If you can please share some dummy data with similar data structure and expected result to help us clarify your requirement and test on it.

How to Get Your Question Answered Quickly  

Notice: please do mask or remove sensitive data before share.
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

You can populate a column in one table using another table. Only this is you need to use aggregate functions 

 

Refer

Max Sales order id = Maxx(filter(sales,Sales[item_id]='Item'[Item ID]),Sales[Order Id]) 
Max customer = MAXX(filter(Sales,Sales[Order Id]='Item'[Max Sales order id] && Sales[item_id]='Item'[Item ID]),Sales[Customer ID])

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

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.