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
mccollough
Helper I
Helper I

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?
1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Screenshot 2021-10-19 060842.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

Screenshot 2021-10-19 060842.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

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?

TheoC
Super User
Super User

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 🙂

 

TheoC_0-1634603752028.png

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

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.