Forum Discussion
Status based on What if Parameter
hi,
I thought this will be easy but I am stuck with this.
I have OTD (OnTimeDelivery) as status.
By defaullt,
NOT YET RECEIVED = Received Date null
NO = Requested Date null or Received Date > Requested Date
YES = Received Date <= Requested Date
Now, we want the OTD to be dynamic based on what if parameter
What if parameter = days difference of received date and requested date.
For example,
What if Parameter: (must use between)
-10 +5
This means, all orders with days difference from -10 up to +5 days will be yes.
the rest will still show as no or not yet received.
Below is my sample data.
| Doc No | Line No | Requested Date | Received Date | DAYS DIFF | OTD | OTD Index |
| 19-00004 | 10000 | null | 1/3/2019 | null | NO | 2 |
| 19-00006 | 10000 | 1/3/2019 | 1/3/2019 | 0 | YES | 1 |
| 19-00007 | 10000 | 1/3/2019 | 1/3/2019 | 0 | YES | 1 |
| 19-00011 | 10000 | 1/3/2019 | 1/6/2019 | 3 | NO | 2 |
| 19-00011 | 20000 | 1/3/2019 | 1/6/2019 | 3 | NO | 2 |
| 19-00011 | 30000 | 1/3/2019 | 1/6/2019 | 3 | NO | 2 |
| 19-00011 | 35000 | 1/3/2019 | 1/6/2019 | 3 | NO | 2 |
| 19-00011 | 37500 | 1/3/2019 | 1/6/2019 | 3 | NO | 2 |
| 19-00021 | 10000 | 1/6/2019 | 1/8/2019 | 2 | NO | 2 |
| 19-00021 | 20000 | 1/6/2019 | 1/8/2019 | 2 | NO | 2 |
| 19-00021 | 30000 | 1/6/2019 | 1/8/2019 | 2 | NO | 2 |
| 19-00021 | 40000 | 1/6/2019 | 1/8/2019 | 2 | NO | 2 |
| 19-00021 | 50000 | 1/6/2019 | 1/8/2019 | 2 | NO | 2 |
| 19-00021 | 60000 | 1/6/2019 | 1/8/2019 | 2 | NO | 2 |
| 19-00021 | 70000 | 1/6/2019 | 1/8/2019 | 2 | NO | 2 |
| 19-00021 | 80000 | 1/6/2019 | 1/8/2019 | 2 | NO | 2 |
| 19-00029 | 10000 | 1/7/2019 | 1/8/2019 | 1 | NO | 2 |
| 19-00029 | 20000 | 1/7/2019 | 1/8/2019 | 1 | NO | 2 |
| 19-00029 | 30000 | 1/7/2019 | 1/8/2019 | 1 | NO | 2 |
| 19-00034 | 10000 | 1/8/2019 | 1/8/2019 | 0 | YES | 1 |
| 19-00036 | 10000 | 1/8/2019 | 1/8/2019 | 0 | YES | 1 |
| 19-00037 | 10000 | 1/10/2019 | 1/13/2019 | 3 | NO | 2 |
| 19-00037 | 20000 | 1/10/2019 | 1/13/2019 | 3 | NO | 2 |
| 19-00038 | 10000 | 1/10/2019 | 1/13/2019 | 3 | NO | 2 |
| 19-00038 | 20000 | 1/10/2019 | 1/13/2019 | 3 | NO | 2 |
| 19-00046 | 10000 | 1/9/2019 | 1/9/2019 | 0 | YES | 1 |
| 19-00059 | 10000 | 1/12/2019 | 1/12/2019 | 0 | YES | 1 |
| 19-00059 | 20000 | 1/12/2019 | 1/12/2019 | 0 | YES | 1 |
| 19-00078 | 10000 | 1/13/2019 | 1/24/2019 | 11 | NO | 2 |
| 19-00082 | 10000 | 1/13/2019 | 1/13/2019 | 0 | YES | 1 |
| 19-00082 | 20000 | 1/13/2019 | 1/13/2019 | 0 | YES | 1 |
| 19-00082 | 30000 | 1/13/2019 | 1/13/2019 | 0 | YES | 1 |
| 19-00082 | 40000 | 1/13/2019 | 1/13/2019 | 0 | YES | 1 |
| 19-00082 | 50000 | 1/13/2019 | 1/13/2019 | 0 | YES | 1 |
| 19-00088 | 10000 | 1/14/2019 | 1/16/2019 | 2 | NO | 2 |
| 19-00089 | 10000 | 1/14/2019 | 1/16/2019 | 2 | NO | 2 |
| 19-00090 | 10000 | 1/14/2019 | 1/14/2019 | 0 | YES | 1 |
| 19-00090 | 20000 | 1/14/2019 | 1/14/2019 | 0 | YES | 1 |
| 19-00090 | 30000 | 1/14/2019 | 1/14/2019 | 0 | YES | 1 |
| 19-00090 | 40000 | 1/14/2019 | 1/14/2019 | 0 | YES | 1 |
| 19-00090 | 50000 | 1/14/2019 | 1/14/2019 | 0 | YES | 1 |
| 19-00090 | 60000 | 1/14/2019 | 1/14/2019 | 0 | YES | 1 |
| 19-00091 | 10000 | null | 1/14/2019 | null | NO | 2 |
| 19-00091 | 20000 | null | 1/14/2019 | null | NO | 2 |
| 19-00091 | 30000 | null | 1/14/2019 | null | NO | 2 |
| 19-00097 | 10000 | 1/15/2019 | 1/24/2019 | 9 | NO | 2 |
| 19-00136 | 10000 | null | 1/24/2019 | null | NO | 2 |
| 19-00136 | 20000 | null | 1/24/2019 | null | NO | 2 |
| 19-00137 | 10000 | 1/20/2019 | 1/20/2019 | 0 | YES | 1 |
| 19-00137 | 20000 | 1/20/2019 | 1/20/2019 | 0 | YES | 1 |
| 19-00137 | 30000 | 1/20/2019 | 1/20/2019 | 0 | YES | 1 |
| 19-00138 | 10000 | 1/21/2019 | 1/20/2019 | -1 | YES | 1 |
| 19-00138 | 20000 | 1/21/2019 | 1/20/2019 | -1 | YES | 1 |
| 19-00138 | 30000 | 1/21/2019 | 1/20/2019 | -1 | YES | 1 |
| 19-00139 | 10000 | null | 1/20/2019 | null | NO | 2 |
| 19-00139 | 20000 | null | 1/20/2019 | null | NO | 2 |
| 19-00139 | 30000 | null | 1/20/2019 | null | NO | 2 |
| 19-00139 | 40000 | null | 1/20/2019 | null | NO | 2 |
| 19-00139 | 50000 | null | 1/20/2019 | null | NO | 2 |
| 19-00198 | 10000 | 1/24/2019 | 1/24/2019 | 0 | YES | 1 |
| 19-00198 | 20000 | null | 1/24/2019 | null | NO | 2 |
| 19-00198 | 30000 | null | 1/24/2019 | null | NO | 2 |
| 19-01158 | 80000 | 4/8/2019 | 4/9/2019 | 1 | NO | 2 |
| 19-01300 | 130000 | 4/17/2019 | 4/17/2019 | 0 | YES | 1 |
| 19-01303 | 130000 | 4/17/2019 | 4/17/2019 | 0 | YES | 1 |
| 19-01387 | 10000 | 5/2/2019 | 5/19/2019 | 17 | NO | 2 |
| 19-01756 | 10000 | 5/27/2019 | null | 21 | NOT YET RECEIVED | 2 |
| 19-02512 | 10000 | 7/22/2019 | null | 23 | NOT YET RECEIVED | 2 |
| 19-02792 | 30000 | 8/6/2019 | null | 0 | NOT YET RECEIVED | 1 |
mussaenda - Create another table with status.
Status
Not yet recieved Yes No Then create another DAX measure
StatusCount = var _status= CALCULATE(SELECTEDVALUE('Status'[Status])) var _gp= CALCULATETABLE(SUMMARIZE(SampleData,SampleData[Doc No],"status",[_OTD Status])) var _count= CALCULATE(COUNTROWS(FILTER(_gp,[status]=_status))) return _countAdd status column into the legend field and add [StatusCount] measure into the value field.
Please mark this solution as accepted, if you find this solution useful.
Regards,
Nandu Krishna
3 Replies
- nandukrishnavs
Community Champion
mussaenda - Try this measure
_OTD Status = VAR minVal = CALCULATE ( MIN ( 'days difference'[days difference] ) ) VAR maxVal = CALCULATE ( MAX ( 'days difference'[days difference] ) ) VAR reqDate = CALCULATE ( SELECTEDVALUE ( SampleData[Requested Date] ) ) VAR resDate = CALCULATE ( SELECTEDVALUE ( SampleData[Received Date] ) ) VAR daysDiff = CALCULATE ( DATEDIFF ( reqDate, resDate, DAY ) ) VAR result = IF ( ISBLANK ( resDate ), "Not yet recieved", IF ( daysDiff >= minVal && daysDiff <= maxVal, "Yes", "No" ) ) RETURN resultYou can find the sample pbix file here https://drive.google.com/open?id=1EbTM2ktkNhWehRxsL55Qyg6njQ4LP1NM
- mussaenda
Community Champion
- nandukrishnavs
Community Champion
mussaenda - Create another table with status.
Status
Not yet recieved Yes No Then create another DAX measure
StatusCount = var _status= CALCULATE(SELECTEDVALUE('Status'[Status])) var _gp= CALCULATETABLE(SUMMARIZE(SampleData,SampleData[Doc No],"status",[_OTD Status])) var _count= CALCULATE(COUNTROWS(FILTER(_gp,[status]=_status))) return _countAdd status column into the legend field and add [StatusCount] measure into the value field.
Please mark this solution as accepted, if you find this solution useful.
Regards,
Nandu Krishna