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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Cant create a direct active relationship

Hello,

 

I am trying to set up a splicer that filters data from two different excel work sheets based on year (Image 1). The splicer correctly shows the number of contractors for the year 2020. However, when I change the splicer to 2021 it doesn't display any number. I tried setting up another relationship between spreadsheet 1 (image 2) and spread 2 (image 3)for the year 2021. However, I keep getting the error in image (4). Any help would be greatly appreciated and let me know if you have any questions.

 

PeterVE_1-1629295365693.png

PeterVE_2-1629295518012.png

 

PeterVE_3-1629295571559.png

 

PeterVE_5-1629295658422.png

 

 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Please try to transform your table like below.

 

staff.gif

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi5JTEszVNJRMjIwMgBSIGwIpmN1oLJGeGWN8cqaQIWBKgzhKuCypnj1mkGFERguZY5XowVeWUu8soYGuG01NMTrG0OkgIKqMERTYYzfABNMu2MB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Staff = _t, #"Year 2020" = _t, #"Year 2021" = _t, #"Count of Year 2020" = _t, #"Count of Year 2021" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Staff", type text}, {"Year 2020", Int64.Type}, {"Year 2021", Int64.Type}, {"Count of Year 2020", Int64.Type}, {"Count of Year 2021", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Count of Year 2020", "Count of Year 2021"}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Removed Columns", {"Staff"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Columns", each ([Value] <> 0)),
    #"Replaced Value" = Table.ReplaceValue(#"Filtered Rows","Year ","",Replacer.ReplaceText,{"Attribute"}),
    #"Renamed Columns" = Table.RenameColumns(#"Replaced Value",{{"Attribute", "Year"}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Renamed Columns",{"Value"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns1",{{"Year", Int64.Type}})
in
    #"Changed Type1"

 

Then you can get this:

year slicer.gif

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

So far I got this to work by splitting the tables and creating a relationship between the data. Any idea on how to merge these two tables? So that it displays staff who worked during 2020 or 2021?

PeterVE_0-1629308519934.png

 

Icey
Community Support
Community Support

Hi @Anonymous ,

 

Please try to transform your table like below.

 

staff.gif

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi5JTEszVNJRMjIwMgBSIGwIpmN1oLJGeGWN8cqaQIWBKgzhKuCypnj1mkGFERguZY5XowVeWUu8soYGuG01NMTrG0OkgIKqMERTYYzfABNMu2MB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Staff = _t, #"Year 2020" = _t, #"Year 2021" = _t, #"Count of Year 2020" = _t, #"Count of Year 2021" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Staff", type text}, {"Year 2020", Int64.Type}, {"Year 2021", Int64.Type}, {"Count of Year 2020", Int64.Type}, {"Count of Year 2021", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Count of Year 2020", "Count of Year 2021"}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Removed Columns", {"Staff"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Columns", each ([Value] <> 0)),
    #"Replaced Value" = Table.ReplaceValue(#"Filtered Rows","Year ","",Replacer.ReplaceText,{"Attribute"}),
    #"Renamed Columns" = Table.RenameColumns(#"Replaced Value",{{"Attribute", "Year"}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Renamed Columns",{"Value"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns1",{{"Year", Int64.Type}})
in
    #"Changed Type1"

 

Then you can get this:

year slicer.gif

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you so much Icey for the video too!!

Anonymous
Not applicable

BUMP

Anonymous
Not applicable

@jaideepnema I have not. How should I unpivot it? I tried in PowerBI but the data became wierd. I am sure I'm not doing it right. I tried to unpivot in power query editor.

@Anonymous is it possible for you to share a sample pbix with sensitive data removed ?

Anonymous
Not applicable

@jaideepnema I tried unpivoting the two year columns but it ended up just duplicating the names regardless if they worked during 2020/2021.

PeterVE_0-1629297027911.png

 

jaideepnema
Solution Sage
Solution Sage

Hi @Anonymous ,

Have you tried unpivot the table(image 3) and then create a active relationship with the unpivoted column. If thats not possible you can create a inactive relationship and then use the userelationship dax function to create a measure to be used in the report.

 

Please accept this as a solution if your question has been answered !!

Appreciate a Kudos 😀

Anonymous
Not applicable

Hi @jaideepnema,

 

I have not tried to unpivot the table. I am worried if I do so then the table wont update when new data is entered into the "master" table.

Hi @Anonymous ,

Are you unpivotting this data in Power BI then it shouldnt be problem.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors