Forum Discussion
dexter2424
Helper I
5 years agoReturn 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...
- 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.
v-yalanwu-msft
Community Support
5 years agoHi, 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.