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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Make the measures dynamic with date range selection.

I am working on a Dahsboard and I have created 3 measues that calcuate the 
inactive clients within 2 years, in active client beyond 2 years, and cross service clients (meaning the number of client who have mutliple projects in differnet service line. I will write the measure below
Also, I have a dete range slicer as filter in the top of the dashboard, the probelm is that the measures are not dynamic with the selected date range ans showed a fixed number that consider all the data source without considering the date range filter

how i can make these measres dynmaic with any date range selection

here is the measures:

InactiveClients_Beyond2Years =
CALCULATE(
    COUNTROWS(
        FILTER(
            VALUES(SQL_Database_Website[NTID]),
            CALCULATE(MAX(SQL_Database_Website[SubmitDate])) <= MAX(SQL_Database_Website[SubmitDate]) - 730
        )
    ),
    ALL(SQL_Database_Website[SubmitDate])
)

 

InactiveClients_Within2Years =
CALCULATE(
    COUNTROWS(
        FILTER(
            VALUES(SQL_Database_Website[NTID]),
            CALCULATE(MAX(SQL_Database_Website[SubmitDate])) > MAX(SQL_Database_Website[SubmitDate]) - 730 &&
            CALCULATE(MAX(SQL_Database_Website[SubmitDate])) <= MAX(SQL_Database_Website[SubmitDate])
        )
    ),
    ALL(SQL_Database_Website[SubmitDate])
)

CrossServiceClients =
CALCULATE(
    COUNTROWS(
        FILTER(
            VALUES(SQL_Database_Website[NTID]),
            CALCULATE(DISTINCTCOUNT(SQL_Database_Website[Type])) > 1
        )
    ),
    ALL(SQL_Database_Website[SubmitDate])
)





 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

 

For your question, in your dax I see that you used "ALL" for filtering. 

 

In fact, "ALL" removes the effect of the slicer. You can modify "ALL" to "ALLSELECTED". 

 

"ALLSELECTED" retains the slicer filter and removes the other filters.

 

Your code should look like this:

InactiveClients_Beyond2Years =
CALCULATE(
    COUNTROWS(
        FILTER(
            VALUES(SQL_Database_Website[NTID]),
            CALCULATE(MAX(SQL_Database_Website[SubmitDate])) <= MAX(SQL_Database_Website[SubmitDate]) - 730
        )
    ),
    ALLSELECTED(SQL_Database_Website[SubmitDate]) -- modify "ALL" to "ALLSELECTED" 
)
 

InactiveClients_Within2Years =
CALCULATE(
    COUNTROWS(
        FILTER(
            VALUES(SQL_Database_Website[NTID]),
            CALCULATE(MAX(SQL_Database_Website[SubmitDate])) > MAX(SQL_Database_Website[SubmitDate]) - 730 &&
            CALCULATE(MAX(SQL_Database_Website[SubmitDate])) <= MAX(SQL_Database_Website[SubmitDate])
        )
    ),
    ALLSELECTED(SQL_Database_Website[SubmitDate])
)

CrossServiceClients =
CALCULATE(
    COUNTROWS(
        FILTER(
            VALUES(SQL_Database_Website[NTID]),
            CALCULATE(DISTINCTCOUNT(SQL_Database_Website[Type])) > 1
        )
    ),
    ALLSELECTED(SQL_Database_Website[SubmitDate])
)

 

Regards,

Nono Chen

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

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous 

 

For your question, in your dax I see that you used "ALL" for filtering. 

 

In fact, "ALL" removes the effect of the slicer. You can modify "ALL" to "ALLSELECTED". 

 

"ALLSELECTED" retains the slicer filter and removes the other filters.

 

Your code should look like this:

InactiveClients_Beyond2Years =
CALCULATE(
    COUNTROWS(
        FILTER(
            VALUES(SQL_Database_Website[NTID]),
            CALCULATE(MAX(SQL_Database_Website[SubmitDate])) <= MAX(SQL_Database_Website[SubmitDate]) - 730
        )
    ),
    ALLSELECTED(SQL_Database_Website[SubmitDate]) -- modify "ALL" to "ALLSELECTED" 
)
 

InactiveClients_Within2Years =
CALCULATE(
    COUNTROWS(
        FILTER(
            VALUES(SQL_Database_Website[NTID]),
            CALCULATE(MAX(SQL_Database_Website[SubmitDate])) > MAX(SQL_Database_Website[SubmitDate]) - 730 &&
            CALCULATE(MAX(SQL_Database_Website[SubmitDate])) <= MAX(SQL_Database_Website[SubmitDate])
        )
    ),
    ALLSELECTED(SQL_Database_Website[SubmitDate])
)

CrossServiceClients =
CALCULATE(
    COUNTROWS(
        FILTER(
            VALUES(SQL_Database_Website[NTID]),
            CALCULATE(DISTINCTCOUNT(SQL_Database_Website[Type])) > 1
        )
    ),
    ALLSELECTED(SQL_Database_Website[SubmitDate])
)

 

Regards,

Nono Chen

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

Anonymous
Not applicable

Thanks a lot, it worked now and it's dynmaic 
I really appreciate your help 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors