Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
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,
Date | Cases |
2020-01-01 | 1 |
2020-01-02 | 2 |
2020-01-03 | 3 |
2020-01-04 | 4 |
2020-01-05 | 5 |
I'd retrieve the previous number of each day, i.e.
Date | Cases | Previous |
2020-01-01 | 1 | |
2020-01-02 | 2 | 1 |
2020-01-03 | 3 | 2 |
2020-01-04 | 4 | 3 |
2020-01-05 | 5 | 4 |
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
whereas I got an expected result if I drag columns into a table viz by order of Date - Cases - Measure.
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! |
@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]))
@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]))
User | Count |
---|---|
12 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
19 | |
14 | |
8 | |
7 |