简体   繁体   中英

How to combine two columns in Power BI

I don't know if the correct thing is to combine the columns but I have the following problem that I would like to solve with you and you can give me a better orientation and it is the following:

I have two excel sheets which I am using as a data source for a report in Power BI, one of these sheets has the following data:

SHEET 1:

在此处输入图像描述

And the other excel sheet with this data:

SHEET 2:

在此处输入图像描述

In the same report I want to represent the information of the two sheets, as you well know in Power BI each excel sheet represents it as a table, but when adding the filter of Location sheet 1 it does not bring me the values of Area C, I understand that it's because I'm filtering by the column Location of sheet 1.

What I want to do is have a global column Location as a filter where the values are found Area A, Area B, Area C, and when executing the filter they are dynamically applied to the data found in sheet 1 and sheet 2.

I don't see any point in having two Location filters with the only difference being that one has more values than the other.

I don't know if the correct thing is to combine the two columns or make a many-to-many relationship, I hope you can guide me to make the best decision.

You should create a Location dimension table in Power Query that combines the values of Sheet1 and Sheet2. Assuming your existing tables are named "Sheet1" and "Sheet2", this Power Query would build the dimension:

let
    Source = Sheet1,
    #"Appended Query" = Table.Combine({Source, Sheet2}),
    #"Removed Other Columns" = Table.SelectColumns(#"Appended Query",{"Location "}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Other Columns")
in
    #"Removed Duplicates"

在此处输入图像描述

Then create a relationship between Locations[Location] and Sheet1[Location], as well as between Locations[Location] and Sheet2[Location]. Then use Locations[Location] in the report.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM