Forum Discussion

nikkirai99's avatar
nikkirai99
Frequent Visitor
1 year ago
Solved

Error fetching data for this visual - column, relationship or measure not in a valid state

I have a Table 1 which is the main table called 'Main' and Table 2 called 'Reason Codes'. 

Table 1 has 100 rows. Table 2 has 5 rows which match Table 1.

 

My calculated column is below:

If(

     Related('Reason Codes'[ReasonCodeDate])=BLANK(),

     BLANK(),

     Related('Reason Codes'[ReasonCodeDate])
)
Why do I get error message in TEST environment?
Error fetching data for this visual
The query referenced column 'Main'[ReasonCodeDate] which depends on another column, relationship or measure that is not in a valid state.

 

Thank you for your help.

 

  • Hi nikkirai99  - Your formula itself is correct for what it intends to do, the way the RELATED function works in DAX and the setup of relationships between your tables.there is a one-to-many relationship between Reason Codes (one side) and Main (many side).

     

    create simple measure as like below for test:

    TestColumn = RELATED('Reason Codes'[ReasonCodeDate])

    If this also results in an error, the issue is with the relationship.  still, If the relationship is valid but still causes issues, try an alternative approach using LOOKUPVALUE

     

    ReasonCodeDateResolved =
    LOOKUPVALUE(
    'Reason Codes'[ReasonCodeDate],
    'Reason Codes'[ReasonCodeID], 'Main'[ReasonCodeID]
    )

     

    This formula does not depend on the RELATED function and works even with inactive relationships.Focus on verifying the relationship between the tables and testing the logic with simpler measures.

     

4 Replies

  • Hi nikkirai99  - Your formula itself is correct for what it intends to do, the way the RELATED function works in DAX and the setup of relationships between your tables.there is a one-to-many relationship between Reason Codes (one side) and Main (many side).

     

    create simple measure as like below for test:

    TestColumn = RELATED('Reason Codes'[ReasonCodeDate])

    If this also results in an error, the issue is with the relationship.  still, If the relationship is valid but still causes issues, try an alternative approach using LOOKUPVALUE

     

    ReasonCodeDateResolved =
    LOOKUPVALUE(
    'Reason Codes'[ReasonCodeDate],
    'Reason Codes'[ReasonCodeID], 'Main'[ReasonCodeID]
    )

     

    This formula does not depend on the RELATED function and works even with inactive relationships.Focus on verifying the relationship between the tables and testing the logic with simpler measures.

     

  • Hi nikkirai99 

    I'm not certain if this is a bug, but I've been encountering it quite frequently lately. My approach is to check if there's a calculated table in the model and add some space at the end. If that's not the issue, I would try renaming the column or refreshing the query.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the reply from danextian  and rajendraongole1 , please allow me to provide another insight:

      Hi, nikkirai99 
       

      Thank you for reaching out to the Microsoft Fabric community forum.

       

      We appreciate you sharing the issue you encountered and pointing out that it might be a known problem. This information is very helpful for other community members who might be facing similar issues.

       

      Additionally, I agree that the alternative solution mentioned by rajendraongole1 is a good idea. You can try using the LOOKUPVALUE() function to temporarily resolve your issue.

      Here is the relevant documentation link:

      LOOKUPVALUE function (DAX) - DAX | Microsoft Learn

       

      Once again, thank you for your contribution. If you have any new discoveries or questions, please feel free to get in touch with us.

       

      Best regards,

      Leroy Lu