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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Txtcher
Helper V
Helper V

How to Filter Measure by Selected Field in Pivot Table

I am new to DAX and the concepts of row vs filter context is way beyond my understanding and confusing as he$$.

I am using Excel Data Model and Power Pivot. The data model is very simple:

Txtcher_0-1732306893362.png

The active relationship between RS Cases and the Date Table is Sent to Region.

I have the following formula which works beautifully when calculating an overall CUMULATIVE count based on the month selected in the pivot:

CALCULATE(
COUNTROWS(RS_Cases),
 
FILTER(
ALL(RS_Cases),
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Status]="OPEN") ||
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Entrance Date]>Max(Date_Table[Date])) ||
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && ISBLANK(RS_Cases[Entrance Date]) && RS_Cases[Status]="CLOSED" && RS_Cases[Status Change Date]>MAX(Date_Table[Date]))
)
)
 
But, if I add a new field to the pivot [Program], the count does not filter to adjust:
Txtcher_1-1732310202885.png

 

I tried creating a Program table, creating a relationship with RS_Cases and inserting a USERELATIONSHIP function, but that doesn't work with the FILTER(ALL...  

Any suggestions?  

And if I add slicers to this pivot, does that affect the way the measure is written?

 

 

 

1 ACCEPTED SOLUTION
Txtcher
Helper V
Helper V

Problem solved after considerable research. This is how I modified the measure:

 

Backlog:=CALCULATE(

COUNTROWS(RS_Cases),

SUMMARIZE(RS_Cases,RS_Cases[Program]),

FILTER(All(RS_Cases),

(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Status]="OPEN" ) ||

(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Entrance Date]>Max(Date_Table[Date])) ||

(RS_Cases[Due By]<=MAX(Date_Table[Date]) && ISBLANK(RS_Cases[Entrance Date]) && RS_Cases[Status]="CLOSED" && RS_Cases[Status Change Date]>MAX(Date_Table[Date])) ) )

 

 

View solution in original post

3 REPLIES 3
Txtcher
Helper V
Helper V

Problem solved after considerable research. This is how I modified the measure:

 

Backlog:=CALCULATE(

COUNTROWS(RS_Cases),

SUMMARIZE(RS_Cases,RS_Cases[Program]),

FILTER(All(RS_Cases),

(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Status]="OPEN" ) ||

(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Entrance Date]>Max(Date_Table[Date])) ||

(RS_Cases[Due By]<=MAX(Date_Table[Date]) && ISBLANK(RS_Cases[Entrance Date]) && RS_Cases[Status]="CLOSED" && RS_Cases[Status Change Date]>MAX(Date_Table[Date])) ) )

 

 

Mahesh0016
Super User
Super User

@Txtcher  I went through your problem statement, but I didn't understand what your end output should be. Can you elaborate precisely?

@Txtcher  Thank You!

The purpose of the report I am building is to track backlogged (overdue) cases.

Each case has the following dates and each of these fields has a relationship with the date table:

- Date Sent to Region

- Due By

- Entrance Date

- Status Change Date

Each case has a Status of either Open or Closed.

A case investigated timely would be: Status = Closed AND the Entrance Date <=Due By date.

The exception to this statement is that some cases are closed without an Entrance Date. In these instance we use the Status Change Date.

The goal is to create a monthly backlog table with a line chart. For example, how many cases were overdue in January 2024?

These are the 3 conditions that would count a case as backlog in January 2024:

1. Due By <=Jan 2024 && Status = "OPEN" ||

2. Due By <=Jan 2024 && Status = "CLOSED" && Entrance Date > Jan 2024 ||

3. Due By <=Jan 2024 && Status = "CLOSED" && IsBlank(EntranceDate) && Status Change Date >Jan 2024

The measure to obtain this count is:

CALCULATE(
COUNTROWS(RS_Cases),
FILTER(
ALL(RS_Cases),
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Status]="OPEN") ||
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Entrance Date]>Max(Date_Table[Date])) ||
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && ISBLANK(RS_Cases[Entrance Date]) && RS_Cases[Status]="CLOSED" && RS_Cases[Status Change Date]>MAX(Date_Table[Date])) ) )

The measure works perfectly to obtain the overall backlog count. The new twist is I now need the same count for each Program. So how do create a new measure that gives me the backlog count by Program? (I will keep the original measure.) I created a Program table with a relationship to the RS_Cases table. I tried adding the UseRelationship function (Program->Program) to the measure, but it has no effect. I think because that is in the CALCULATE part and not included in the FILTER part (sorry inelegant way of describing it but I'm green here). 

Also, I will want the user to be able to select the Program using a slicer (not sure if that affects how the measure is written).

Thanks for any help you can give.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.