cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MR2001
Helper II
Helper II

Filtering records based on a slicer

I have the following calculated column that works correctly:

 

Total PCR = 
VAR Date1 = 'Table1'[date]
RETURN
CALCULATE (
SUM ('Table1'[Total] ),
FILTER (
'Table1',
'Table1'[date] <= Date1), 
FILTER( 'Table1', 'Table1'[Request_Type] = "Defect")
)

 

If I remove however the highlighted part and add a slicer based on [Request_Type] instead, it does not work correctly anymore. I was hoping a filter will change the way column calculates but it doesn't... Selecting "Defect" from the slicer does not produce the same result.

[Request_Type] column has three possible values: "Defect", "Enhancement", "Change".

 

How can I make it work based on a filter/slicer?

1 ACCEPTED SOLUTION
Greg_Deckler
Super User IV
Super User IV

Have you tried creating that as a measure instead of a calculated column?


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Greg_Deckler
Super User IV
Super User IV

Have you tried creating that as a measure instead of a calculated column?


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Problem solved.
Measure:

 

Total PCR1 =
CALCULATE (
SUM ('Table1'[Total]),
FILTER ( ALL ('Table1'), Table1'[date] <= MAX ( Table1'[date] ) ),
VALUES(Table1[Request_Type] )
)

 

Note: the key was adding VALUES(Table1[Request_Type] ) as demonstrated in: http://community.powerbi.com/t5/Desktop/DAX-Running-total-by-another-column/m-p/10517#M2191

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors