Forum Discussion
Calculation based on two dates
- 3 years ago
Hi , DataFab2023
Thanks for your quick response!I may have a mistake in my dax code , you can try to use this dax:
Measure = var _slicer =MAX('Dim_Date2'[Date Filter]) var _start = MINX( FILTER(ALLSELECTED('Sheet1'),'Sheet1'[Date]=_slicer) , [Start]) var _date = MAX('Sheet1'[Date]) return IF(_date>=_start && _date<= _slicer,1,0)Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi , DataFab2023
Thanks for you sample .pbix file firsr~
Here are the steps you can refer to :
We can click "New Measure" to create a measure like this:
Measure = var _slicer =MAX('Dim_Date2'[Date Filter])
var _start = MINX( FILTER('Sheet1','Sheet1'[Date]=_slicer) , [Start])
var _date = MAX('Sheet1'[Date])
return
IF(_date>=_start && _date<= _slicer,1,0)
Then we can put this measure on the "Filter on this visual" for this visual:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- DataFab20233 years agoFrequent Visitor
Hi there,
thanks for taking the time for this one.
The measure almost worked, the problem is that when I select 15/04/2023 for example the start period (from the start column) is 01/04/2023 there it should show data only from 01/04/2023 and not 15/01/2023- v-yueyunzh-msft3 years agoCommunity Support
Hi , DataFab2023
Thanks for your quick response!I may have a mistake in my dax code , you can try to use this dax:
Measure = var _slicer =MAX('Dim_Date2'[Date Filter]) var _start = MINX( FILTER(ALLSELECTED('Sheet1'),'Sheet1'[Date]=_slicer) , [Start]) var _date = MAX('Sheet1'[Date]) return IF(_date>=_start && _date<= _slicer,1,0)Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly