Today, in our Power BI series, Let's discuss how you can perform join operation using DAX function in Power BI.
As a data analyst, you should be proficient in DAX formulas as they are really powerful and allow you to analyze data in a detailed manner.
So, to perform join in Power BI, the DAX function is:
1) NATURALINNERJOIN(<left table>,<right table>): It allows you to perform inner join between the two tables.
2) NATURALLEFTOUTERJOIN(<left table>,<right table>): It performs a left outer join between the two tables.
Some things to keep in mind:
-- Now note that, you should have a column which is common in both the table.
-- The name of columns should be same in both the tables.
Also, if you are facing some issues to perform this join operation even after doing everything right, the possible issue can be from the fact that Power BI is having issues in joining according to the column that is common.
It can be because of the fact that Power BI only wants unique values as the key and can throw an error if the rows of the key are not unique.
Also, many times, you also don't get all the columns that you want after the join and I have faced these issues multiple times, so to solve this:
-- Use "SELECTCOLUMNS" to select appropriate columns that you want in your result. Also, include "common column (key)" in this and ensure name is same for key.
-- Also, the key that is creating the problem in joining, use "VALUE" function so that only distinct values are provided to the function.
-- Now perform the join.
Example:
EmpTitles=NATURALINNERJOIN(SELECTCOLUMNS('Merge1',"emp_no",VALUE(Merge1[emp_no]),"salary",Merge1[publicsalaries.salary],"department",Merge1[public.departments.dept_name]),SELECTCOLUMNS('public titles',"emp_no",VALUE('public titles'[emp_no]),"titles",'public titles'[title]))
Here:
EmpTitles ---> result table
Merge1 ---> Table 1
public titles ---> Table 2
#PowerBI #DAX #JoinOperations #NATURALINNERJOIN #NATURALLEFTOUTERJOIN #DataAnalytics #DataAnalyst #DataTransformation #DAXFunctions #PowerBItips #BusinessIntelligence #BItools #AnalyticsSkills #DataModeling #TableJoins #DataAnalysis #USData #UKData #EuropeData #USTech #UKTech #EuropeTech #DataScienceUSA #DataScienceUK #DataScienceEurope #EUData #DataEngineering #NorthAmericaData #UKBusiness #EuropeanTech