Forum Discussion

S3's avatar
S3
Helper III
3 years ago
Solved

PreviousDay for First Date in Dataset

Hello,  I have a dataset which begins on the 01st of January 2022 and ends on the 31st of July 2022.  I also have a date slicer the user can choose from and a graph showing the value of previo...
  • v-yalanwu-msft's avatar
    3 years ago

    Hi, S3 ;

    Try it.

    Previous Period Value = 
    var _a= CALCULATE([Value Measure]
    	                             ,DATESBETWEEN(
    									 Dates[Date],
    									 [Start of Previous Period],
    				    				 [End of Previous Period]),
    									 ALL(Dates))
    var _diff2=DATEDIFF( CALCULATE(MIN('Dates'[Date]),ALLSELECTED(Dates)),CALCULATE(MAX('Dates'[Date]),ALLSELECTED(Dates)),DAY)
    var _diff1=DATEDIFF( CALCULATE(MIN('Dates'[Date]),ALL(Dates)),CALCULATE(MIN('Dates'[Date]),ALLSELECTED(Dates)),DAY)
    return IF(CALCULATE(SUM('Table'[value]),ALL('Table'))=_a||_diff1<_diff2,BLANK(), _a)
    

    The final show:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.