Forum Discussion
PreviousDay for First Date in Dataset
- 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.
Hello lbendlin,
You've once helped me with a similar concept regarding previous month value. I've tried changing in your previous measure for this case, however I simply got the value of the same date and not the previous.
This case also has an aditional point of having a selected period of time, and wishing to get N/A when the number of current period's days is greater than the number of the previous days'.
Do you have an idea about that please?
- lbendlin3 years agoSuper User
Keep in mind that if you want to use time intelligence functions then your calendar table must be contiguous and must also cover the result of the calculation.
- S33 years agoHelper III
Hello lbendlin ,
thanks for your reply. I actually changed my previous Dataset from monthly to daily, so now I have all dates in my Calender.- lbendlin3 years agoSuper User
Please provide sanitized sample data that fully covers your issue.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.