Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Relateadtable used in calculate function at calculate column based on inactive relationship

Hi , team I'm at lost when using relatedtable in calculate function at calculate column. The detail is as follows. <Data> Sales -->Sales can oocur at different location with same produ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

    For the table "Product", you can do some processing in Power Query Editor as shown below, so that it will be easier to make some calculation later.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjQwMDBU0lECYSMgBvN1wUJQppFSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, Location1 = _t, Location2 = _t, Key1 = _t, Key2 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Location1", Int64.Type}, {"Location2", Int64.Type}, {"Key1", type text}, {"Key2", type text}}),
        #"Unpivoted Only Selected Columns1" = Table.Unpivot(#"Changed Type", {"Location2", "Location1"}, "Attribute.1", "Location"),
        #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Unpivoted Only Selected Columns1", {"Key1", "Key2"}, "Attribute", "Key"),
        #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Only Selected Columns",{"Attribute.1", "Attribute"})
    in
        #"Removed Columns"

    If the above one can't help you, could you please provide more raw data and the specific examples to explain your expected result( Is it 400)? It would be helpful to find out the solution. You can refer the following links to share the required info:

    How to provide sample data in the Power BI Forum

    Best Regards