Forum Discussion

mccollough's avatar
mccollough
Helper I
4 years ago
Solved

Making Measures Ignore Filters

Hi Everyone,

 

Here is a simplified version of my table called 'Employee Performance'

Employee           Location     ShiftTask Type       Task Value        Work Volume           Report Date              
John DoeOfficeFirst RotationAB0.75110/10/2021
Jane DoeHomeSecond RotationAB1210/10/2021
BatmanBat CaveThird RotationCD0.25110/10/2021
John DoeOfficeFirst RotationCD0.75210/10/2021
BatmanBat CaveThird RotationEF0.25310/10/2021
John DoeHomeThird RotationAB0.75110/11/2021
Jane DoeBat CaveFirst RotationAB1.5210/11/2021
BatmanOfficeSecond RotationCD0.5610/11/2021
John DoeHomeThird RotationEF0.75110/11/2021
John DoeBat CaveFirst RotationCD0.75210/12/2021
Jane DoeOfficeThird RotationEF0.75310/12/2021
BatmanHomeSecond RotationAB1410/12/2021
John DoeBat CaveFirst RotationAB0.75210/12/2021
John DoeOfficeFirst RotationCD1.5310/13/2021
Jane DoeHomeThird RotationEF0.5110/13/2021
BatmanBat CaveSecond RotationAB0.25410/13/2021
Jane DoeHomeThird RotationCD0.25210/13/2021
BatmanBat CaveSecond RotationUS0.75110/13/2021
Ned FlandersHomeThird RotationUS0.33210/14/2021
Bart SimpsonOfficeFirst RotationAB1310/14/2021
John DoeHomeThird RotationEF1110/15/2021
Jane DoeBat CaveSecond RotationCD0.25210/15/2021
BatmanOfficeFirst RotationCD0.5110/15/2021
John DoeHomeSecond RotationAB0.5110/16/2021
John DoeBat CaveFirst RotationEF0.25410/17/2021
BatmanOfficeThird RotationAB0.75210/17/2021
John DoeBat CaveSecond RotationCD0.75610/17/2021
Jane DoeOfficeFirst RotationAB0.25110/17/2021
BatmanHomeThird RotationEF0.75110/17/2021
Jane DoeOfficeThird RotationUS0.75210/18/2021
BatmanHomeSecond RotationCD0.33210/18/2021
John DoeOfficeFirst RotationAB1110/18/2021


I'm trying to return the total work volume for the last 3 days by location.

Here's the DAX I have:

WeeklySumByLocation =
CALCULATE
(
SUM('Employee Performance'[Work Volume]),
VALUES('Employee Performance'[Location]),
FILTER
(
'Employee Performance',
DATE ( YEAR ( NOW () ), MONTH ( NOW () ), DAY ( NOW () - 2)) <= MAX('Employee Performance'[Report Date])
)
)

It returns 27 for Location = BatCave, but it should only return 10. Why?

Also, I'd like to display this total for the last 3 days on a graph that simultaneously displays the total for a user-defined date range via a page-level filter. How do I get this DAX formula to ignore that page-level filter?

3 Replies

  • TheoC's avatar
    TheoC
    Community Champion

    Hi mccollough 

     

    Currently, your measure looks to be returning the number of rows (i.e. 27).

     

    Can you give the following a go (adjust Table Names to your relevant table name... I called mine tblBatMan :D)  I've also added the "ALL ('tblBatman')" at the end to ignore filters 🙂

     

     

    mea_New = 
    
    VAR _StartDate = LASTDATE ( 'tblBatMan'[Report Date] )
    VAR _EndDate = MAX ( tblBatMan[Report Date] ) - 2
    
    RETURN
    
    CALCULATE ( SUM ( tblBatMan[Work Volume] ) , FILTER ( 'tblBatMan' , _StartDate <= MAX ( 'tblBatMan'[Report Date] ) && 'tblBatMan'[Report Date] >= _EndDate ) , FILTER ('tblBatMan' , tblBatMan[Location] = "Bat Cave" ) , ALL ('tblBatman') )

     

     

    You should get 10 🙂

     

     

    • mccollough's avatar
      mccollough
      Helper I

      That worked splendidly! One last question though, I noticed that the page filter will still effect the measure if the number of days passed is less than 3. Any idea how to make it ignore that?