Forum Discussion

dexter2424's avatar
dexter2424
Icon for Helper I rankHelper I
5 years ago
Solved

Return latest policy status

Hi All,   I need help in PowerBI because cannot figure out how to solve this issue. I would like to return the latest policy status up to the maximum selected date by policy number. for examp...
  • v-yalanwu-msft's avatar
    5 years ago

    Hi, dexter2424 

     

    You could create two measures by the following formula:

    Open =
    VAR _last =
        CALCULATE (
            COUNT ( [Policy] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                [Reported Start Date] = MAX ( [Reported Start Date] )
                    && [Status] = "Open"))
    VAR _count =
        CALCULATE (
            DISTINCTCOUNT ( [Policy] ),
            FILTER ( ALLSELECTED ( 'Table' ), [Status] = "Open" ))
    RETURN
        IF ( _last = BLANK (), IF ( _count = 1, 0, -1 ), _last )
    
    Close =
    VAR _last =
        CALCULATE (
            COUNT ( [Policy] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                [Reported Start Date] = MAX ( [Reported Start Date] )
                    && [Status] = "Close"))
    VAR _count =
        CALCULATE (
            DISTINCTCOUNT ( [Policy] ),
            FILTER ( ALLSELECTED ( 'Table' ), [Status] = "Close" )
        )
    RETURN
        IF ( _last = BLANK (), IF ( _count = 1, 0, -1 ), _last )
    

    The final output is shown below:

     

    Best Regards,
    Community Support Team_ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.