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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

All Except does not work when filtering by measure

Hello,

 

I have a table of policies which have start dates and end dates. The goal of this dashboard is to show active policies at the date range that is filtered for. A policy is active for a certain date range if its start date occurs before the select month/year and ends after the selected month/year. Therefore the flag for active policies will change depending on which dates the user selects.

 

In addition, I have multiple policy snapshots for the same policy and only want to show one, which would be the one with the most recent start date. See example below (assuming march 2023 is the selected date range).

policy numbereffective dateend dateactive
13/4/202312/1/20231
13/8/202312/1/20231
12/1/20232/28/20230
15/1/20236/1/20230

 

In this case, I would only show the second row (with an effective date of 3/8/2023).

 

To do this, I created a measure flag that determines if a policy snapshot is active for the given time frame. Remember this could change. So if the user selects February 2023, only the 3rd row would be considered active and given a 1. 

 

I tried the following:

 

CALCULATE(MAX(table1[EffectiveDate],ALLEXCEPT(policynumber),filter(table1,activeMeasure=1))

 

However this gave me the following:

policy numbereffective dateend dateactiveMaximum effective date
13/4/202312/1/202313/4/2023
13/8/202312/1/202313/8/2023

 

when what I want is this:

policy numbereffective dateend dateactiveMaximum effective date
13/4/202312/1/202313/8/2023
13/8/202312/1/20231

3/8/2023

 

 

I played around it with some more and fouund that when I remove the measure filter(table1,active=1) clause, I get the following:

policy numbereffective dateend dateactiveMaximum effective date
13/4/202312/1/202315/1/2023
13/8/202312/1/202315/1/2023

 

I have been playing around with it for a while and cannot figure out how to fix this. I tried creating virtual tables within the measure but it gives me the same result. 

 

How can I get the max date for each unique policy for the date range selected?

2 REPLIES 2
grazitti_sapna
Super User
Super User

Hey, Try using the below measure where Testing_1 is the source table and create a table with the following query:

SUMMARIZE(FILTER(Testing_1,Testing_1[Active]=1),Testing_1[Effective Date],Testing_1[End Date],Testing_1[Policy Number],"Max_date",CALCULATE(MAX(Testing_1[Effective Date]),ALLEXCEPT(Testing_1,Testing_1[Policy Number]),Testing_1[Active]=1))

lbendlin
Super User
Super User

You are looking for ALLSELECTED, not ALLEXCEPT.

 

lbendlin_0-1680998710610.png

see attached

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.