Forum Discussion
ammar_cs_2004
3 years agoFrequent Visitor
How to create start and end date columns from date column in Power BI?
I need to make the start date and end date columns from the date column. I have a table of Asset transfer
Example Input:
| Vr. No. | Vr. Date | Transaction Name | Asset Code | To Code | To Name |
| 15127 | 31/12/2017 | Asset Custodian Opening | 56521 | C1 | Company 1 |
| 151 | 10/07/2019 | Asset Transfer Custodian | 56521 | C2 | Company 2 |
| 5904 | 23/12/2021 | Asset Transfer Custodian | 56521 | C3 | Company 3 |
Expected Output:
| Asset Code | Index | Start Date | End Date | Code | Name |
| 56521 | 0 | 31/12/2017 | 09/07/2019 | C1 | Company 1 |
| 56521 | 1 | 10/07/2019 | 22/12/2021 | C2 | Company 2 |
| 56521 | 2 | 23/12/2021 | today date | C3 | Company 3 |
How to do it on power bi ?
- Anonymous3 years ago
Hi ammar_cs_2004,
You can try to use the following calculate column formula to get the end date:
EndDate = VAR nextDate = CALCULATE ( MIN ( 'Table'[Vr. Date] ), FILTER ( 'Table', [Asset Code] = EARLIER ( 'Table'[Asset Code] ) && [Vr. Date] > EARLIER ( 'Table'[Vr. Date] ) ) ) RETURN IF ( nextDate <> BLANK (), nextDate - 1, TODAY () )Regards,
Xiaoxin Sheng
2 Replies
- AnonymousNot applicable
Hi ammar_cs_2004,
You can try to use the following calculate column formula to get the end date:
EndDate = VAR nextDate = CALCULATE ( MIN ( 'Table'[Vr. Date] ), FILTER ( 'Table', [Asset Code] = EARLIER ( 'Table'[Asset Code] ) && [Vr. Date] > EARLIER ( 'Table'[Vr. Date] ) ) ) RETURN IF ( nextDate <> BLANK (), nextDate - 1, TODAY () )Regards,
Xiaoxin Sheng
- ammar_cs_2004Frequent Visitor
thanks Xiaoxin Sheng it is working fine.