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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
SS0101
New Member

Using Calculate function with two tables

hi guys,

I'm struggling with the following problem:

I have two tables:

1. projects table. each row represents a project that has a "start date" and "End date"

2. regular calendar table

 

I want to add a column to the calendar table that calculates how many active projects were on this day. 

tried to work with a straightforward calculate function but got the same result for each date:

Active Projects =
VAR S_date = SELECTEDVALUE('Calendar Table'[Date])
RETURN
    calculate(
        COUNTROWS(project table),
        FILTER(project table,
            project table[start date] <= S_date  && project table[end date]>=S_date))

what am I missing here? thanks in advance folks
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @SS0101 ,

 

You can try the following measure:

Measure =
var _select=SELECTEDVALUE('Calendar Table'[Date])
return
COUNTX(
    FILTER(ALL('projects table'),
    _select>='projects table'[StartDate]&&_select<='projects table'[EndDate]),[project])

vyangliumsft_0-1704097371842.png

vyangliumsft_1-1704097371843.png

Or add an ALL() function to the original Dax.

ALL function (DAX) - DAX | Microsoft Learn

If it doesn't meet your desired outcome, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi  @SS0101 ,

 

You can try the following measure:

Measure =
var _select=SELECTEDVALUE('Calendar Table'[Date])
return
COUNTX(
    FILTER(ALL('projects table'),
    _select>='projects table'[StartDate]&&_select<='projects table'[EndDate]),[project])

vyangliumsft_0-1704097371842.png

vyangliumsft_1-1704097371843.png

Or add an ALL() function to the original Dax.

ALL function (DAX) - DAX | Microsoft Learn

If it doesn't meet your desired outcome, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

thanks Liu Yang!

that nearly solved my issues, however - In this setup, I can't use any slicer (doesn't have any effect). is it due to the ALL command? how can it be worked around?

 

thanks

 

lbendlin
Super User
Super User

You would need to inactivate the relationship between the calendar table and the projects table. Then for your visual use the date from the calendar table for the axis and your measure as the data.

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.

Top Solution Authors