Forum Discussion
Matrix column filtered by another column being not blank
Hello, I have data like below (only in reality it has much more values for all columns):
| KEY | VALUE | TIME | FLAG |
| 50 | 74 | 1 | YES |
| 50 | 11 | 2 | |
| 50 | 13 | 3 | YES |
| 50 | 9 | 4 | |
| 50 | 6 | 5 | |
| 51 | 62 | 1 | |
| 51 | 100 | 2 | |
| 51 | 67 | 3 | |
| 51 | 36 | 4 | |
| 51 | 53 | 5 | YES |
| 52 | 52 | 1 | |
| 52 | 57 | 2 | |
| 52 | 69 | 3 | |
| 52 | 60 | 4 | |
| 52 | 36 | 5 |
I'm making a matrix of them (KEY as row, TIME as column, VALUE as value):
However, I would need to filter the matrix so that only TIME that has FLAG=YES on ANY row is shown. If TIME has a FLAG=YES for any KEY, the value for all KEYs should be shown. Meaning that in the test data, only TIME 1, 3 and 5 should show. Like this:
If I put in Power BI FLAG=YES as advanced filter in the visual, naturally KEY 52 is dropped completely and I don't get all values for 50 and 51:
So it is right to show only TIME 1, 3 and 5 but I need to see all the values for all the keys.
The setup needs to be dynamic when I filter the keys. E.g. if I choose to look at only key 51, matrix shows only TIME 5 because it is the only timepoint that has FLAG=YES for KEY 51:
I have tried to do a measure that should count the amount of FLAG=YES for each TIMEpoint and filter the matrix visual with the measure, but it is not working:
Thanks!
2 Replies
- eliasayyy
Memorable Member
hello mhinia
create a new calculated tableAllKeyTimeCombinations = CROSSJOIN(VALUES('Table'[KEY]), VALUES('Table'[Time]))
add the key and time to from the new table to the column and row
create new measureFiltered Value = VAR CurrentKey = SELECTEDVALUE('AllKeyTimeCombinations'[KEY]) VAR CurrentTime = SELECTEDVALUE('AllKeyTimeCombinations'[Time]) RETURN CALCULATE(SUM('Table'[Value]), 'Table'[KEY] = CurrentKey, 'Table'[Time] = CurrentTime, 'Table'[Flag] = "YES")
add the measure to values
on the build a visual panel , right click on Key and select show items with no data, do the same for time
result:
if you need all the values, then what's the point of flag?- mhiniaFrequent Visitor
Hi. Thank you! To clarify, the desired output is:
The point of FLAG is to filter out TIME 2 and 4 because those values have no FLAG=YES in any row.
For example, the FLAG=YES for KEY=50 in TIME=1 could mean that there was an error at the data point that is flagged, and I want to see what value KEY 50 and all the other keys get at that time.