Forum Discussion

mussaenda's avatar
mussaenda
Icon for Community Champion rankCommunity Champion
6 years ago
Solved

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 NoLine NoRequested DateReceived DateDAYS DIFFOTDOTD Index
19-0000410000null1/3/2019nullNO2
19-00006100001/3/20191/3/20190YES1
19-00007100001/3/20191/3/20190YES1
19-00011100001/3/20191/6/20193NO2
19-00011200001/3/20191/6/20193NO2
19-00011300001/3/20191/6/20193NO2
19-00011350001/3/20191/6/20193NO2
19-00011375001/3/20191/6/20193NO2
19-00021100001/6/20191/8/20192NO2
19-00021200001/6/20191/8/20192NO2
19-00021300001/6/20191/8/20192NO2
19-00021400001/6/20191/8/20192NO2
19-00021500001/6/20191/8/20192NO2
19-00021600001/6/20191/8/20192NO2
19-00021700001/6/20191/8/20192NO2
19-00021800001/6/20191/8/20192NO2
19-00029100001/7/20191/8/20191NO2
19-00029200001/7/20191/8/20191NO2
19-00029300001/7/20191/8/20191NO2
19-00034100001/8/20191/8/20190YES1
19-00036100001/8/20191/8/20190YES1
19-00037100001/10/20191/13/20193NO2
19-00037200001/10/20191/13/20193NO2
19-00038100001/10/20191/13/20193NO2
19-00038200001/10/20191/13/20193NO2
19-00046100001/9/20191/9/20190YES1
19-00059100001/12/20191/12/20190YES1
19-00059200001/12/20191/12/20190YES1
19-00078100001/13/20191/24/201911NO2
19-00082100001/13/20191/13/20190YES1
19-00082200001/13/20191/13/20190YES1
19-00082300001/13/20191/13/20190YES1
19-00082400001/13/20191/13/20190YES1
19-00082500001/13/20191/13/20190YES1
19-00088100001/14/20191/16/20192NO2
19-00089100001/14/20191/16/20192NO2
19-00090100001/14/20191/14/20190YES1
19-00090200001/14/20191/14/20190YES1
19-00090300001/14/20191/14/20190YES1
19-00090400001/14/20191/14/20190YES1
19-00090500001/14/20191/14/20190YES1
19-00090600001/14/20191/14/20190YES1
19-0009110000null1/14/2019nullNO2
19-0009120000null1/14/2019nullNO2
19-0009130000null1/14/2019nullNO2
19-00097100001/15/20191/24/20199NO2
19-0013610000null1/24/2019nullNO2
19-0013620000null1/24/2019nullNO2
19-00137100001/20/20191/20/20190YES1
19-00137200001/20/20191/20/20190YES1
19-00137300001/20/20191/20/20190YES1
19-00138100001/21/20191/20/2019-1YES1
19-00138200001/21/20191/20/2019-1YES1
19-00138300001/21/20191/20/2019-1YES1
19-0013910000null1/20/2019nullNO2
19-0013920000null1/20/2019nullNO2
19-0013930000null1/20/2019nullNO2
19-0013940000null1/20/2019nullNO2
19-0013950000null1/20/2019nullNO2
19-00198100001/24/20191/24/20190YES1
19-0019820000null1/24/2019nullNO2
19-0019830000null1/24/2019nullNO2
19-01158800004/8/20194/9/20191NO2
19-013001300004/17/20194/17/20190YES1
19-013031300004/17/20194/17/20190YES1
19-01387100005/2/20195/19/201917NO2
19-01756100005/27/2019null21NOT YET RECEIVED2
19-02512100007/22/2019null23NOT YET RECEIVED2
19-02792300008/6/2019null0NOT YET RECEIVED1

 

 

 

  • 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 _count

    Add 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's avatar
    nandukrishnavs
    Icon for Community Champion rankCommunity 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
        result

     

    You can find the sample pbix file here https://drive.google.com/open?id=1EbTM2ktkNhWehRxsL55Qyg6njQ4LP1NM

      • nandukrishnavs's avatar
        nandukrishnavs
        Icon for Community Champion rankCommunity 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 _count

        Add 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