Forum Discussion
Jyaulhaq
2 years agoFrequent Visitor
Previous Date
Dear ,
i have data: Month and Date(measures) like:
Date(measures)=max(table[Date])
| Month | Date(Measures) |
| Jan | 10/1/2024 |
| Feb | 20/2/2024 |
| March | 11/3/2024 |
| April | 10/4/2024 |
| May | |
| Jun | 19/06/2024 |
how can i get previous date like:
| Month | Measures Pre |
| Jan | 01/01/2024 |
| Feb | 10/1/2024 |
| March | 20/2/2024 |
| April | 11/3/2024 |
| May | |
| Jun | 10/4/2024 |
Hi Jyaulhaq, you can achieve the desired result using the following calcualtion:
Measures Pre = VAR _CurrentDate = SELECTEDVALUE( 'Table'[Date] ) //get the current date VAR _GlobalMin = //get the global minimum CALCULATE( MIN( 'Table'[Date] ), ALL( 'Table' ) //to remove impact of any other column from the same table ) VAR _PrevDate = //PrevDate CALCULATE( MAX( 'Table'[Date] ), ALL( 'Table' ), //to remove impact of any other column from the same table (such as "Month") 'Table'[Date] < _CurrentDate ) RETURN IF( _CurrentDate = _GlobalMin, //so the first row is selected DATE( YEAR( TODAY() ), 1, 1 ), //the date you need _PrevDate )
Here is the output:
Have a great day!
1 Reply
- Sergii24Super User
Hi Jyaulhaq, you can achieve the desired result using the following calcualtion:
Measures Pre = VAR _CurrentDate = SELECTEDVALUE( 'Table'[Date] ) //get the current date VAR _GlobalMin = //get the global minimum CALCULATE( MIN( 'Table'[Date] ), ALL( 'Table' ) //to remove impact of any other column from the same table ) VAR _PrevDate = //PrevDate CALCULATE( MAX( 'Table'[Date] ), ALL( 'Table' ), //to remove impact of any other column from the same table (such as "Month") 'Table'[Date] < _CurrentDate ) RETURN IF( _CurrentDate = _GlobalMin, //so the first row is selected DATE( YEAR( TODAY() ), 1, 1 ), //the date you need _PrevDate )
Here is the output:
Have a great day!