Forum Discussion
Count How Many Times a Date Crosses A Milestone
Hi
I would like to count the number of times that a date crosses a milestone.
For example in the below table the CURRENT ARTS from the ORIGINAL RTS crosses Date 1 and Date 2 so therefore the answer would be 2 times. I may have upto 5 dates that the Current ARTS crosses.
| Equipment ID | Original RTS | Current ARTS | Actual ARTS | Date 1 | Date 2 |
| 12345 | Wednesday, 25 February 2015 | Tuesday, 23 December 2014 | Tuesday, 20 January 2015 | Sunday, 1 December 2014 | Sunday, 14 December 2014 |
Would appreciate any assitance in this space
Thanks
Hi, drwillia
You can try the following methods.
In the Power Query, Transform-Unpivot other column:
Result:
Measure = VAR _org_rts = CALCULATE(MAX('Table'[Value]), FILTER('Table','Table'[Attribute]="Original RTS")) VAR _cur_arts = CALCULATE(MAX('Table'[Value]), FILTER('Table','Table'[Attribute]="Current ARTS")) VAR _table = FILTER('Table',LEFT('Table'[Attribute],4)="Date") Return COUNTROWS(FILTER(_table,'Table'[Value]>=_org_rts&&'Table'[Value]<=_cur_arts))Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
6 Replies
- Greg_Deckler
Community Champion
drwillia Not quite understanding this. Do you mean that since the Current ARTS date is greater than both Date 1 and Date 2 that it "crosses" those those dates?
- drwillia
Helper I
Hi Greg,
yes but the original RTS date was also before those two dates. So the current RTS date has progressed from the orignal date to the current date and crossed over Date 1 and Date 2 in doing so.
Hoep that makes sense
Thanks
- drwillia
Helper I
Greg_Deckler Hi Greg are you able to help me?
- v-zhangti
Community Support
Hi, drwillia
You can try the following methods.
In the Power Query, Transform-Unpivot other column:
Result:
Measure = VAR _org_rts = CALCULATE(MAX('Table'[Value]), FILTER('Table','Table'[Attribute]="Original RTS")) VAR _cur_arts = CALCULATE(MAX('Table'[Value]), FILTER('Table','Table'[Attribute]="Current ARTS")) VAR _table = FILTER('Table',LEFT('Table'[Attribute],4)="Date") Return COUNTROWS(FILTER(_table,'Table'[Value]>=_org_rts&&'Table'[Value]<=_cur_arts))Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- drwillia
Helper I
Hi v-zhangti Greg_Deckler thanks very much guys, much appreciated!
- Syndicate_Admin
Administrator
@Syndicate_Admin Hello. My Spanish is bad. Thanks a lot!