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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

BUG: RELATED does not work in one to many relation

While creating a new model I wanted to use the RELATED function to get the a value from the one-side table into the many-side table. This failed with the error:

 

 

The column 'Rules[Criteria]' either doesn't exist or doesn't have a relationship to any table available in the current context.

 

 


This happens both in the latest version as well as in the May 2020 version of PowerBI.
I simplified the model to contain just 2 tables with static data and the same error still occurs. You can easily reconstruct the model following the steps below:

1. Create a new empty PBIX file

2. Add the Rules table using the statemement below (one-side)

3. Add the Rulevalues table using the statemement below (many-side)

The relation between both is automatically created using the RuleID values, defined as Single, one to many.

 

This looks like the schoolbook version of how to use RELATED, yet it does not work. I can't see why.

 

Rules table can be created using:

 

 

let
    Source = Table.FromRecords({
        [RuleID=90, Category = "Code", Enabled=true, Guidance="Rule1", Criteria = "...", Penalty=5, ValidFrom="2018-1-1",ValidUntil="2019-12-31"],
        [RuleID=100, Category = "Code", Enabled=true, Guidance="Rule2", Criteria = "...", Penalty=10, ValidFrom="2020-1-1",ValidUntil="2021-3-31"],
        [RuleID=110, Category = "Code", Enabled=false, Guidance="Rule3", Criteria = "...", Penalty=10, ValidFrom="2020-1-1",ValidUntil=null],
        [RuleID=120, Category = "Code", Enabled=false, Guidance="Rule4", Criteria = "...", Penalty=5, ValidFrom="2020-7-1",ValidUntil=null],
        [RuleID=200, Category = "Beveiliging", Enabled=true, Guidance="Rule5", Criteria = "...", Penalty=25, ValidFrom="2020-1-1",ValidUntil=null],
        [RuleID=300, Category = "Cloud", Enabled=true, Guidance="Rule6", Criteria = "...", Penalty=5, ValidFrom="2020-1-1",ValidUntil=null],
        [RuleID=400, Category = "Process", Enabled=true, Guidance="Rule7", Criteria = "...", Penalty=15, ValidFrom="2020-1-1",ValidUntil=null]
        }),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"RuleID", Int64.Type}, {"Category", type text}, {"Guidance", type text}, {"Criteria", type text}, {"Penalty", Int64.Type}, {"ValidFrom", type date}, {"ValidUntil", type date}})
in
    #"Changed Type"

 

 

 

Rulevalues can be created using:

 

 

let
    Source = Table.FromRecords({
    [Timestamp="2020-11-14", ComponentID=1, RuleID=100, Outcome="Y"],
    [Timestamp="2020-11-14", ComponentID=1, RuleID=200, Outcome="N"],
    [Timestamp="2020-11-14", ComponentID=1, RuleID=300, Outcome="Y"],

    [Timestamp="2020-11-14", ComponentID=2, RuleID=100, Outcome="NA"],
    [Timestamp="2020-11-14", ComponentID=2, RuleID=200, Outcome="Y"],
    [Timestamp="2020-11-14", ComponentID=2, RuleID=400, Outcome="NA"],

    [Timestamp="2020-11-14", ComponentID=4, RuleID=100, Outcome="Y"],
    [Timestamp="2020-11-14", ComponentID=4, RuleID=200, Outcome="Y"],
    [Timestamp="2020-11-14", ComponentID=4, RuleID=400, Outcome="Y"],

    [Timestamp="2020-11-14", ComponentID=3, RuleID=100, Outcome="N"],
    [Timestamp="2020-11-14", ComponentID=3, RuleID=200, Outcome="N"],
    [Timestamp="2020-11-14", ComponentID=3, RuleID=400, Outcome="N"]
}),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Timestamp", type date}, {"ComponentID", Int64.Type}, {"RuleID", Int64.Type}, {"Outcome", type text}})
in
    #"Changed Type"

 

 

 

 

Status: New
Comments
v-chuncz-msft
Community Support

@JBJBJB 

 

That works fine for me. Make sure it is a calculated column, not measure.