Forum Discussion
Difference between date and run if
Hi i have the following sample table, and i want to achieve the following.Each product can have multiple event nos.
a) Calculate date difference between 1st and last events for same product
b) Mark all event nos more than 2 days and less than 30 days for same product as Re-Event, excluding 1st Event.
| Product | Event No | Date |
| Product 1 | 3663328-501 | 7/27/2019 |
| Product 1 | 4377204-502 | 7/28/2019 |
| Product 1 | 8524894-501 | 7/29/2019 |
| Product 1 | 9478521-501 | 7/30/2019 |
| Product 2 | 9478521-502 | 6/15/2019 |
| Product 2 | 9478521-503 | 2/15/2019 |
| Product 2 | 9478521-507 | 8/15/2019 |
| Product 3 | 9478521-508 | 6/15/2019 |
| Product 3 | 9478521-509 | 5/27/2019 |
| Product 3 | 9478521-510 | 7/20/2019 |
| Product 3 | 9478521-511 | 7/27/2018 |
| Product 3 | 9478521-512 | 3/27/2019 |
| Product 3 | 9478521-514 | 3/28/2019 |
| Product 3 | 9841725-501 | 2/15/2019 |
| Product 2 | 9841725-502 | 6/16/2019 |
| Product 2 | 9841725-503 | 4/15/2019 |
| Product 4 | 9841725-505 | 3/27/2019 |
| Product 4 | 9841725-506 | 2/17/2019 |
| Product 4 | 9841725-507 | 3/24/2019 |
| Product 4 | 0227975-501 | 3/27/2019 |
| Product 4 | 0227975-502 | 6/15/2019 |
| Product 4 | 0227975-504 | 3/27/2019 |
| Product 5 | 0227975-506 | 7/27/2019 |
| Product 5 | 0227975-507 | 1/27/2019 |
| Product 5 | 0495169-501 | 7/27/2019 |
| Product 5 | 0495169-504 | 7/29/2019 |
| Product 5 | 0495169-505 | 7/30/2019 |
| Product 5 | 0495169-506 | 7/31/2019 |
| Product 5 | 1160976-501 | 6/15/2019 |
| Product 5 | 1160976-502 | 2/15/2019 |
| Product 5 | 1160976-503 | 2/17/2019 |
| Product 5 | 1160976-504 | 7/29/2019 |
| Product 5 | 1160976-505 | 7/30/2019 |
| Product 5 | 1160976-506 | 3/27/2019 |
| Product 5 | 1160976-507 | 3/27/2019 |
6 Replies
- Nathaniel_CCommunity Champion
Hi Mahadevaraobc ,
Here is the event span, have to do something else, will be back.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
NathanielEvent Span = DATEDIFF(FIRSTDATE(Event[Date]),LASTDATE(Event[Date]),DAY)
- MahadevaraobcHelper II
Hi Nathaniel_C,
Thanks for replying, this answers part of my question, could you help me with the other question...
- Nathaniel_CCommunity Champion
Hi Mahadevaraobc ,
Here you go. Will post code in a minute.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel- Nathaniel_CCommunity Champion
Interesting issue, hope this helps.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
NathanielHere is my pbix https://1drv.ms/u/s!AgCd7AyfqZtExjCwBgNzr63TFQaz?e=dg6Nzh
First date = CALCULATE(MIN(Event[Date]),Event[Date],FIRSTDATE(Event[Date])) Elapsed Time = Var StartDate = CALCULATE(MIN(Event[Date]),Filter(ALLSELECTED(Event),min(Event[Date]))) Return DATEDIFF(StartDate,Event[First date],DAY) Is Re-event = IF([Elapsed Time]>3&& [Elapsed Time]<30,"Re-Event","") Event Span = DATEDIFF(FIRSTDATE(Event[Date]),LASTDATE(Event[Date]),DAY)
- MahadevaraobcHelper IIThank you will check and get back...