Forum Discussion
Using isBlank to return blank when no value provided in a field
- 7 years ago
Hi CMcMahan,
After futzing w/this a bit, I finally got it to work correctly with this DAX:
Updated PR MS Indicator calc
M_Task MS RYG2 =
If(
isBlank(Max('taskbaselines'[Task Baseline Finish Date])),
BLANK(),
If(MAX('Tasks'[Task Finish Variance Days])<=7,"https://Aristocratgaming.sharepoint.com/sites/pwa/_api/Projectdata/_layouts/15/inc/PWA/images/cf_6p.png" ,
if(MAX('tasks'[Task Finish Variance Days])>=21,"https://Aristocratgaming.sharepoint.com/sites/pwa/_api/Projectdata/_layouts/15/inc/PWA/images/cf_2p.png" ,
)))
Ah, yes. Matrix vs table.
Every value in a matrix is assummed to be some sort of aggregation of data, grouped by the current row(s) and column(s). Values in a table are just pulled directly from a table. You were able to create the calculated table with no issues, but now the matrix is trying to aggregate those values.
You should be able to use this measure instead to return the proper value with the code:
SELECTEDVALUE('Taskbaselines'[task baseline finish date],BLANK())This will select the first value from whatever the current filter context is, or null if there are no options or multiple options.
If you start having problems with totals showing up that you don't want, you can see my recent adventure fighting with a matrix here: https://community.powerbi.com/t5/Desktop/Only-Total-Select-Values-in-a-Matrix-amp-Formatting-Help/m-p/710741#M343163
Hello Cmcmahan,
I was able to work in the Selected Value option you outlined in the following calculation
- Cmcmahan7 years ago
Resident Rockstar
Hmm... that looks like it should work. So we get to start debugging.
Can you create a few test measures and put them into the table for me?
Test1 = SELECTEDVALUE('TaskBaselines'[Task Baseline Finish Date])Test2 = 'tasks'[Task Finish Variance Days]
If you don't get the expected values for these, then we know what part of the main C_Task MS RYG2 indicator we need to examine/fix.
- Clint7 years ago
Helper V
Hi CMcMahan,
After futzing w/this a bit, I finally got it to work correctly with this DAX:
Updated PR MS Indicator calc
M_Task MS RYG2 =
If(
isBlank(Max('taskbaselines'[Task Baseline Finish Date])),
BLANK(),
If(MAX('Tasks'[Task Finish Variance Days])<=7,"https://Aristocratgaming.sharepoint.com/sites/pwa/_api/Projectdata/_layouts/15/inc/PWA/images/cf_6p.png" ,
if(MAX('tasks'[Task Finish Variance Days])>=21,"https://Aristocratgaming.sharepoint.com/sites/pwa/_api/Projectdata/_layouts/15/inc/PWA/images/cf_2p.png" ,
)))
- Cmcmahan7 years ago
Resident Rockstar
Nice man! That looks good! Glad you were able to figure it out
- Clint7 years ago
Helper V
Hi CMcMahan,
So, I had an opportunity to work w/this some more today and found - if I use a measure in the TaskBaselines table, I am getting closer to the right result.M_Task MS RYG2 =If(Not isBlank(Max('taskbaselines'[Task Baseline Finish Date])),(SELECTEDVALUE('TaskBaselines'[Task Baseline Finish Date],If(max('Tasks'[Task Finish Variance Days])<=7,"https://Aristocratgaming.sharepoint.com/sites/pwa/_api/Projectdata/_layouts/15/inc/PWA/images/cf_6p.png" ,if(max('tasks'[Task Finish Variance Days])>=21,"https://Aristocratgaming.sharepoint.com/sites/pwa/_api/Projectdata/_layouts/15/inc/PWA/images/cf_2p.png" ,This returns nothing for the cell that should be blank but, for the other cells that should have an indicator, it is returning the baseline date.