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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
android1
Post Patron
Post Patron

Count if date is earlier than a date in related table

Hi,

 

Trying to count the number of CarerRef if the StartDate  was before the date in a related table.

 

Trying -> Count Carer Ref = CALCULATE(COUNTROWS(CarersList),CarersList[CarerRef],CarersList[StartDate] < RELATEDTABLE(vw_ShiftsAll),vw_ShiftsAll[iDate])

 

Getting error The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

 

Any ideas what I need to change?

 

1 ACCEPTED SOLUTION

Hi @android1

 

Please give this calculated column a go.

 

Column = 
    CALCULATE(
        COUNTROWS('vw_ShiftsAll'),
        'vw_ShiftsAll'[iDate] > EARLIER('CarersList'[StartDate])
        )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

3 REPLIES 3
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @android1

 

Do you want this to be a calculated column or calculated measure?

 

Which table is on the One side of the one-to-many relationship between 'CarersList' and 'vw_ShiftsAll' ?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hi @Phil_Seamark,

 

I'd like it as a calculated measure. Here's my relationship.Relship.png

 

 

Hi @android1

 

Please give this calculated column a go.

 

Column = 
    CALCULATE(
        COUNTROWS('vw_ShiftsAll'),
        'vw_ShiftsAll'[iDate] > EARLIER('CarersList'[StartDate])
        )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.