Forum Discussion
Getting previous date by category, not min date
- 4 years ago
Thanks for clearer explanation, below you can try the new measure for the different of the days compare to previous ID.
Measure =var forid = SELECTEDVALUE('Table'[ID])var selectdate = SELECTEDVALUE('Table'[Date])var previousdate = CALCULATE(MAX('Table'[Date]),FILTER(ALL('Table'),'Table'[ID]=forid-1))var result = DATEDIFF(previousdate,selectdate,DAY)returnIF(previousdate=BLANK(),BLANK(),result)
Another measure is the status:Status =var forid = SELECTEDVALUE('Table'[ID])var forcategory = SELECTEDVALUE('Table'[Category])var result = CALCULATE(MAX('Table'[Category]),FILTER(ALL('Table'),'Table'[ID]=forid-1))returnIF(result=BLANK(), BLANK(), IF(forcategory<>result, "Change", "No Change"))Hope this can help you.
- 4 years ago
Hi Anonymous
If the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.
Looking forward to your feedback.
Best Regards,
Henry
Maybe, you can show me what is the result you wanted from this table, i believe that i will have a better understanding on your requirement.
Thanks, I am testing your measure but not getting the right result. this is a better sample of the actual data. as I add new records I need to compare to the previous date, when I add ID 2, compare to ID 1, when I add ID 3, compare to ID 2. Below sample shows ID 5, I need to compare to ID 4. Using Min and Max return ID 1 and ID 5 which is not what I need to check for name change. Thank for your help
| ID | Category | Date | Status | Days |
| 1 | aName | 7/27/22 | ||
| 2 | aName | 8/10/22 | No Change | 14 days |
| 3 | aName | 8/17/22 | No Change | 21 Days |
| 4 | bName | 8/25/22 | Change | 1 Days |
| 5 | bName | 9/1/22 | No Change | 6 Days |
- Chew_WenJie4 years ago
Resolver III
Thanks for clearer explanation, below you can try the new measure for the different of the days compare to previous ID.
Measure =var forid = SELECTEDVALUE('Table'[ID])var selectdate = SELECTEDVALUE('Table'[Date])var previousdate = CALCULATE(MAX('Table'[Date]),FILTER(ALL('Table'),'Table'[ID]=forid-1))var result = DATEDIFF(previousdate,selectdate,DAY)returnIF(previousdate=BLANK(),BLANK(),result)
Another measure is the status:Status =var forid = SELECTEDVALUE('Table'[ID])var forcategory = SELECTEDVALUE('Table'[Category])var result = CALCULATE(MAX('Table'[Category]),FILTER(ALL('Table'),'Table'[ID]=forid-1))returnIF(result=BLANK(), BLANK(), IF(forcategory<>result, "Change", "No Change"))Hope this can help you.
- Anonymous4 years agoNot applicable
Thank you, I will try this on Tuesday when I return to work and let you know.
I really appreciate the help
- v-henryk-mstf4 years ago
Community Support
Hi Anonymous
If the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.
Looking forward to your feedback.
Best Regards,
Henry