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
CNENFRNL
Community Champion
Community Champion

Filter context of table viz

Dear gurus,

Once again, I can't wrap head around a seemingly silly simple question: what is the filter context of a table viz?

I even came across a funny scene in this regard.

Here's a very simple dataset,

DateCases
2020-01-011
2020-01-022
2020-01-033
2020-01-044
2020-01-055

 

I'd retrieve the previous number of each day, i.e. 

DateCasesPrevious
2020-01-011 
2020-01-0221
2020-01-0332
2020-01-0443
2020-01-0554

 

here's the measure

 

Measure = 
VAR __prev = MAX ( DS[Date] ) - 1
RETURN CALCULATE ( MAX ( DS[Cases] ), DS[Date] = __prev )

When I drag columns into a table viz by order of Cases - Date - Measure, I got ONLY BLANK TABLE

 

Screenshot 2020-11-08 234000.png

whereas I got an expected result if I drag columns into a table viz by order of Date - Cases - Measure.

Screenshot 2020-11-08 234222.png

 

No any other viz, slicers or filters exist in my scenario. Therefore, I suspect that such a funny scene results from the filter context, which influence the calculation of the measure. I googled but it turned out (perhaps I didn't find) any explicit clarification of such a subject: what on earth is the filter context of a table viz? what's even more, could it be possible that order of columns in table viz produce different filter context?

 

Your help would be highly appreciated! TIA

(I attached the file for your trial)


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!

2 REPLIES 2
amitchandak
Super User
Super User

@CNENFRNL , Try a new column like

Column = maxx(FILTER('Table (2)', 'Table (2)'[Date] <EARLIER('Table (2)'[Date])),LASTNONBLANKVALUE('Table (2)'[Date],'Table (2)'[Cases]))

 

Screenshot 2020-11-09 07.23.29.png

wdx223_Daniel
Super User
Super User

@CNENFRNL that did not happen in my computer, whatever the order of draging columns into Table viz, the result is normal and correct, depending on the field of Cases is Whole Number.

but ,when the Cases is in Text type, the result is blank like yours, even change the order to drag the columns, it is still blank.

then i adjusted the code to add a filter statement, the normal result came back.

 

Measure = 
VAR __prev = MAX ( DS[Date] ) - 1
RETURN CALCULATE ( MAX ( DS[Cases] ), DS[Date] = __prev ,ALL(DS[Cases]))

 

 

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.

Top Solution Authors