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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
LearnToFly
Frequent Visitor

Data Model Relationships

I have inherited an older dashboard with a preexisting data model which has a start time field that I tried to relate to a new table I created...through another field called workday.  So the relationship exists there was no error when it was created.  However, it will not allow me to compare two-time fields.  When I tried to use related to verify the relationship...it says The column 'Call Detail Record[Start_Time - Time]' either doesn't exist or doesn't have a relationship to any table available in the current context.  I have checked data types...both are long-time formats, and I have checked correct naming conventions and precision.  I have little experience with data modeling and I feel like it's the relationship because there isn't a primary key and it has to relate to a foreign key but I'm not sure what the workaround for this is.

 

I've tried just an IF, RELATED, and RELATEDTABLE...here is my code:

Business Hours =
IF (
'Hours_Of_Operation'[Start_Of_Day1] = RELATEDTABLE('Call Detail Record')[Start_Time -Time] ||
'Hours_Of_Operation'[Start_Of_Day2] = RELATEDTABLE('Call Detail Record')[Start_Time - Time],
"COUNT",
"DON'T COUNT"
)

 

*Creating a composite key didn't seem to work either.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @LearnToFly ,

You can update the formula of calculated column [Business Hours] as below:

Business Hours = 
VAR _count =
    CALCULATE (
        COUNT ( 'Call Detail Record'[Start_Time -Time] ),
        FILTER (
            'Call Detail Record',
            'Call Detail Record'[Start_Time -Time]
                IN { 'Hours_Of_Operation'[Start_Of_Day1], 'Hours_Of_Operation'[Start_Of_Day2] }
        )
    )
RETURN
    IF ( _count > 0, "COUNT", "DON'T COUNT" )

vyiruanmsft_0-1697164105190.png

 

If the above one can't help you get the expected result, please provide some raw data in your table (exclude sensitive data) with Text format and the relationship info between the tables. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @LearnToFly ,

You can update the formula of calculated column [Business Hours] as below:

Business Hours = 
VAR _count =
    CALCULATE (
        COUNT ( 'Call Detail Record'[Start_Time -Time] ),
        FILTER (
            'Call Detail Record',
            'Call Detail Record'[Start_Time -Time]
                IN { 'Hours_Of_Operation'[Start_Of_Day1], 'Hours_Of_Operation'[Start_Of_Day2] }
        )
    )
RETURN
    IF ( _count > 0, "COUNT", "DON'T COUNT" )

vyiruanmsft_0-1697164105190.png

 

If the above one can't help you get the expected result, please provide some raw data in your table (exclude sensitive data) with Text format and the relationship info between the tables. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.