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
leok
Employee
Employee

Calculated column do not respect page filter

Hi all.

I have some data like this:

 
idDateDim1
id101.01.2020A
id201.02.2020A
id301.02.2020A
id401.02.2020B

 

I want to show on report how many lines we have on given date (incling all previous dates)

I created a calculated column:

CountOnDate = CALCULATE(DISTINCTCOUNT('Table'[id]); FILTER('Table'; 'Table'[Date]<=EARLIER('Table'[Date])))
 
This gives me results exactly as I want:
powerbi-1.PNG
 
And I created a line chart and set it to display MAX(CountOnDate).
Also I added Dim1 as page filter.
 
The problem is that when I select in filter Dim1=A I expect to  see CountOnDate only for A (1 on 01-01-2020 and 3 on 01-02-2020).
powerbi-2.PNG
 
As I understand page filters can not affect filter context in DAX formulas. Then how can I achieve desired result (Display "Accumulated Count on date" respecting all user filters)?
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

In your case, you have created a column where count of max is precalculated. so it will not work. This need to create as a measure, such measure need all to be used to you have to have a dimension table

Refer solution: https://www.dropbox.com/s/nbqn94k2fw2oaow/maxcount.pbix?dl=0

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

In your case, you have created a column where count of max is precalculated. so it will not work. This need to create as a measure, such measure need all to be used to you have to have a dimension table

Refer solution: https://www.dropbox.com/s/nbqn94k2fw2oaow/maxcount.pbix?dl=0

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

That you very much, amitchandak.

 

I was even able to simplify your solution to not require additional table: 

CountOnDate2 = CALCULATE(DISTINCTCOUNT(Sheet1[id]);FILTER(ALL(Sheet1[Date]);Sheet1[Date]<=max(Sheet1[Date]) ))
 
However, my solution not works if I replace Date with Date hierarchy - in that case it gives same as count(id), while your solution works in both cases.
hnguy71
Memorable Member
Memorable Member

@leok ,

Place your ID into the tooltips field and it should work.

 



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

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.