Forum Discussion
ALobo94
2 years agoNew Member
Dynamic difference between dates present in a single column based on slicer selection
Hi, I have a sample data in the following format in an excel. Serial No Tax Invoice Stage 1 Stage 2 Stage 3 1 T1 3/23/2024 3/27/2024 4/6/2024 2 T2 3/28/2024 4/27/2024 4/29/2024...
- Anonymous2 years ago
Hi ALobo94
You can refer to the following solution.
1.It is better that unpivot the column to the following format in power query.
2.Create the following measures.
theDateDifference = VAR _maxdate = CALCULATE ( MAX ( 'Table'[Value] ), ALLSELECTED ( 'Table' ), 'Table'[Tax Invoice] IN VALUES ( 'Table'[Tax Invoice] ), 'Table'[Stage] IN VALUES ( 'Table'[Stage] ) ) VAR _mindate = CALCULATE ( MIN ( 'Table'[Value] ), ALLSELECTED ( 'Table' ), 'Table'[Tax Invoice] IN VALUES ( 'Table'[Tax Invoice] ), 'Table'[Stage] IN VALUES ( 'Table'[Stage] ) ) RETURN DATEDIFF ( _mindate, _maxdate, DAY )Date Difference = AVERAGEX(VALUES('Table'[Tax Invoice]),[theDateDifference])Then put the date difference measure to the visual.
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
2 years agoNot applicable
Hi ALobo94
You can refer to the following solution.
1.It is better that unpivot the column to the following format in power query.
2.Create the following measures.
theDateDifference =
VAR _maxdate =
CALCULATE (
MAX ( 'Table'[Value] ),
ALLSELECTED ( 'Table' ),
'Table'[Tax Invoice] IN VALUES ( 'Table'[Tax Invoice] ),
'Table'[Stage] IN VALUES ( 'Table'[Stage] )
)
VAR _mindate =
CALCULATE (
MIN ( 'Table'[Value] ),
ALLSELECTED ( 'Table' ),
'Table'[Tax Invoice] IN VALUES ( 'Table'[Tax Invoice] ),
'Table'[Stage] IN VALUES ( 'Table'[Stage] )
)
RETURN
DATEDIFF ( _mindate, _maxdate, DAY )
Date Difference = AVERAGEX(VALUES('Table'[Tax Invoice]),[theDateDifference])
Then put the date difference measure to the visual.
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.