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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ChemEnger
Advocate IV
Advocate IV

DAX Calculated Column with FILTER won't respond to Slicers

I have a table of Work Orders (All Work Orders) and I would like to see date-by-date how many were in an open (or overdue) state.

Each Work Order has (amongst other things):

  • [WO Number] - String, Index
  • [Department] - String
  • [Orgination Date/Time] - Date/Time
  • [Completion Date/Time] - Date/Time
  • [WO Complete] - Boolean

I also have a WO Type from a Dimension Table (WO Types)

Finally, I have built a Date Table to act as the X-axis of a chart:

DateTable - CALENDARAUTO(12)

And added calculated columns.  For the Open WOs column in DateTable, I have:

Open WOs = 
CALCULATE(
COUNTROWS('All Work Orders'),
FILTER(ALLSELECTED('All Work Orders'),'All Work Orders'[Origination Date/Time]<=DateTable[Date]),
FILTER(ALLSELECTED('All Work Orders'),'All Work Orders'[Completion Date/Time]>=DateTable[Date] || NOT('All Work Orders'[WO Complete]))
)
Which works, but does not respond to other slicers on the report, which I have red-underlined in the Model view screenshot below. I had orignally tried just the FILTER command and have tried also KEEPFILTERS but nothing that I do seems to work!
 

Model View of All Work Orders & DateTableModel View of All Work Orders & DateTable

4 REPLIES 4
amitchandak
Super User
Super User

@ChemEnger , New table, and new columns will not respond to the slicer filter. You need to create a measure.

Thanks for the super-quick reply @amitchandak,

 

Where / how would the measure go in that case please?

So - very nearly there thanks @amitchandak!

Using your blog as a guide, I added two inactive relationships between DateTable and All Work Orders and added the measure [Open WOs] to the All Work Orders table:

Revised Model view with relationship between DateTable and All Work OrdersRevised Model view with relationship between DateTable and All Work Orders

The measure is as below

Open WOs = 
CALCULATE(
COUNTx(
FILTER('All Work Orders',
'All Work Orders'[Origination Date/Time]<=MAX('DateTable'[Date]) && ('All Work Orders'[WO Complete]=FALSE()
|| 'All Work Orders'[Completion Date/Time]>MAX('DateTable'[Date]))),('All Work Orders'[WO Number])
)
)

I had to make one small adjustment and change the [Date] Column in DateTable to Date instead of Date/Time, otherwise it was looking at 00:00:00 so out by one day. 

This measure now works with the slicers 🙂

The only question now (please!) is, is there any way of getting the maximum for any period when I Drill up in the chart (this was easy before as I could just tell the column to summarise by Maximum but this isn't possible with a measure) rather than (I am guessing) the value for the last day of the month.

As an example, here's the difference on a month-by-month basis of the two:

Comparison between number of records using Calculated Column against MeasureComparison between number of records using Calculated Column against Measure

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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