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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
ChemEnger
Advocate IV
Advocate IV

Filter on a measure

Hi,

 

I feel that this should be simple but my solution isn't working.

 

I have some records that belong to various departments that have an [Outcome] of either Within Target or Overdue.  I have a chart that shows the total  count of each for each department, broken down by [Outcome]:

ChemEnger_0-1594636086671.png

I would like to be able to filter the chart to show only the departments that have Overdue records, but still show those that are Within Target as well. I have a count of Overdue records but when I add [Count of Overdue] >0 to the visual filter, it only shows the Overdue records:

ChemEnger_1-1594636204797.png

 

 

 

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @ChemEnger 

for example, you can try to add a column

Department has Overdue records = 
var _count = CALCULATE(COUNTROWS(Table), ALLEXCEPT(Table, Table[Department]), Table[Count of Overdue] > 0)
RETURN
IF(_count > 0, TRUE(), FALSE())

then filter by this column


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@ChemEnger , Try like

countx(filter(summarize(Table,Table[department],"_1",[Count of Overdue] ),[_1]>0),[department])

az38
Community Champion
Community Champion

Hi @ChemEnger 

for example, you can try to add a column

Department has Overdue records = 
var _count = CALCULATE(COUNTROWS(Table), ALLEXCEPT(Table, Table[Department]), Table[Count of Overdue] > 0)
RETURN
IF(_count > 0, TRUE(), FALSE())

then filter by this column


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Thanks @az38,

 

I got an error when I tried to use the expression as you'd suggested:

"A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed."

 

I think this is because the [Count of Overdue] that I had was a measure, not a column.  I tweaked it slightly and got exactly what I needed:

Department has Overdue records =
var _count = CALCULATE(COUNTROWS(Table), ALLEXCEPT(Table, Table[Department]), Table[Outcome]="Overdue")
return
IF(_count > 0, TRUE(), FALSE())

 

All sorted now and working perfectly with the new column as a filter 👍

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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