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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

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.