Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jakob82
Frequent Visitor

Question regarding filter on CALCULATE PREVIOUSDAY and DATESYTD

Hi

 

I have a measure like this: 

 

Amount Previous Day:=CALCULATE([Amount], PREVIOUSDAY('Dim Date'[Balance Date]), DATESYTD('Dim Date'[Balance Date]))

 

and it works like i expected. But when I read about CALCULATE I don't get exactly why it is working..

 

 When i filter on period August, in the report, it still shows the previous day Amount for 1 of August, which is Amount for july 31. I thought the context was modified when I filter on August and therfore should not be a previous day amount? Why is it working like this?

 

jakob82_0-1696669868848.png

 

1 ACCEPTED SOLUTION
Dangar332
Super User
Super User

hi, @jakob82 


you use  DATESYTD('Dim Date'[Balance Date]) function which give you dates of year which you currently itrrated. means if you current date is 2023-08-01 then it give you date from (2023-01-01) to (2023-08-01)

so your calculate filter expression filter date from (2023-01-01) to (2023-08-01).

 

use DATESMTD('Dim Date'[Balance Date]) which give you date only currently ittarated month

means your current date = 2023-08-10 then   DATESMTD('Dim Date'[Balance Date]) give you (2023-08-01) to (2023-08-10)

Amount Previous Day:=CALCULATE([Amount], PREVIOUSDAY('Dim Date'[Balance Date]), DATESMTD('Dim Date'[Balance Date]))

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly. Appreciate your kudos

View solution in original post

2 REPLIES 2
Dangar332
Super User
Super User

hi, @jakob82 


you use  DATESYTD('Dim Date'[Balance Date]) function which give you dates of year which you currently itrrated. means if you current date is 2023-08-01 then it give you date from (2023-01-01) to (2023-08-01)

so your calculate filter expression filter date from (2023-01-01) to (2023-08-01).

 

use DATESMTD('Dim Date'[Balance Date]) which give you date only currently ittarated month

means your current date = 2023-08-10 then   DATESMTD('Dim Date'[Balance Date]) give you (2023-08-01) to (2023-08-10)

Amount Previous Day:=CALCULATE([Amount], PREVIOUSDAY('Dim Date'[Balance Date]), DATESMTD('Dim Date'[Balance Date]))

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly. Appreciate your kudos

hi , @jakob82 

is there your solution

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.