Forum Discussion
SWITCH measure includes blank/empty rows based on DATEDIFF-column
- 1 year ago
You can modify your Diff days measure to handle blanks explicitly. Here’s a revised version of your Diff days measure:
Diff days =
IF (
ISBLANK ( MAXX ( RELATEDTABLE ( MANUFACTURING_ORDERS ), MANUFACTURING_ORDERS[Order Due] ) ),
BLANK(),
DATEDIFF (
MAXX ( RELATEDTABLE ( MANUFACTURING_ORDERS ), MANUFACTURING_ORDERS[Order Due] ),
ITEM_TRANSACTION_HISTORY_SUM[Date],
DAY
)
)This modification checks if the [Order Due] date is blank and returns BLANK() if it is. Otherwise, it calculates the date difference as before.
Next, you can update your Status Order measure to handle these blank values:
Status Order =
SWITCH (
TRUE(),
ISBLANK ( ITEM_TRANSACTION_HISTORY_SUM[Diff days] ), BLANK(),
ITEM_TRANSACTION_HISTORY_SUM[Diff days] < -1, "Too soon",
ITEM_TRANSACTION_HISTORY_SUM[Diff days] > 1, "Too late",
ITEM_TRANSACTION_HISTORY_SUM[Diff days] = 1 ||
ITEM_TRANSACTION_HISTORY_SUM[Diff days] = 0 ||
ITEM_TRANSACTION_HISTORY_SUM[Diff days] = -1, "OK"
)By adding the ISBLANK check at the beginning of your SWITCH statement, you ensure that any blank values in the Diff days column are handled appropriately and do not return “OK” by default.
Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!
You can modify your Diff days measure to handle blanks explicitly. Here’s a revised version of your Diff days measure:
Diff days =
IF (
ISBLANK ( MAXX ( RELATEDTABLE ( MANUFACTURING_ORDERS ), MANUFACTURING_ORDERS[Order Due] ) ),
BLANK(),
DATEDIFF (
MAXX ( RELATEDTABLE ( MANUFACTURING_ORDERS ), MANUFACTURING_ORDERS[Order Due] ),
ITEM_TRANSACTION_HISTORY_SUM[Date],
DAY
)
)
This modification checks if the [Order Due] date is blank and returns BLANK() if it is. Otherwise, it calculates the date difference as before.
Next, you can update your Status Order measure to handle these blank values:
Status Order =
SWITCH (
TRUE(),
ISBLANK ( ITEM_TRANSACTION_HISTORY_SUM[Diff days] ), BLANK(),
ITEM_TRANSACTION_HISTORY_SUM[Diff days] < -1, "Too soon",
ITEM_TRANSACTION_HISTORY_SUM[Diff days] > 1, "Too late",
ITEM_TRANSACTION_HISTORY_SUM[Diff days] = 1 ||
ITEM_TRANSACTION_HISTORY_SUM[Diff days] = 0 ||
ITEM_TRANSACTION_HISTORY_SUM[Diff days] = -1, "OK"
)
By adding the ISBLANK check at the beginning of your SWITCH statement, you ensure that any blank values in the Diff days column are handled appropriately and do not return “OK” by default.
Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!