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.
Hello PBI People!
I am struggling with a merge task and I'm hoping for some clarity and assistance on the issue.
I have two tables, Policies and Risks
Policies records the policyId every single day that a policy remains active
Risks contains info about different risk vehicles linked to a policy (one policy can have many vehicles)
I have included a screenshot of an example of the two tables as well as the merged table I am trying to create. I basically want to map each riskvehicleid to every instance of the policyid in the policies table.
I am not too sure how to go about it Power BI, my last attempt only pulled one row into the merged table.
Please advise!
Thank you in advance
Solved! Go to Solution.
Hi @HB13 ,
You can achieve this goal in power query:
First, choos merge queries as new:
Then select table and choose inner join:
Expand risk and remove useless column:
Final output:
Here is the M code:
let
Source = Table.NestedJoin(Policies, {"policyid"}, Risk, {"policyid"}, "Risk", JoinKind.Inner),
#"Expanded Risk" = Table.ExpandTableColumn(Source, "Risk", {"policyid", "riskvehicleid", "vehiclemanufactureyear"}, {"Risk.policyid", "Risk.riskvehicleid", "Risk.vehiclemanufactureyear"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Risk",{"Risk.policyid"})
in
#"Removed Columns"
Kind Regards,
Bubble
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @HB13 ,
Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.
Refer to:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @HB13 ,
You can achieve this goal in power query:
First, choos merge queries as new:
Then select table and choose inner join:
Expand risk and remove useless column:
Final output:
Here is the M code:
let
Source = Table.NestedJoin(Policies, {"policyid"}, Risk, {"policyid"}, "Risk", JoinKind.Inner),
#"Expanded Risk" = Table.ExpandTableColumn(Source, "Risk", {"policyid", "riskvehicleid", "vehiclemanufactureyear"}, {"Risk.policyid", "Risk.riskvehicleid", "Risk.vehiclemanufactureyear"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Risk",{"Risk.policyid"})
in
#"Removed Columns"
Kind Regards,
Bubble
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@HB13 , Based on what I got. Create a combine column or policy and date in both tables and use that in merge
Are you saying combine date and policyid in a column? There isn't a date column in the Risks table to do so
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
88 | |
70 | |
61 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |