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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
sarjensystems1
Helper III
Helper III

Want to calculate before data for selected date (may exists or not in master table)

Hello All,

 

I want to calculate before value for selected date. for example I have a master table having data from 'Apr-2020' to 'Apr-2021'.
and I have selected 15-oct-2020 , then the measure should calculate Data from Starting date i.e. 'Apr-2020' till '15-oct-2020'.

Thanks in advance.

3 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@sarjensystems1 If you have proper date table you can use DATESBETWEEN as filter for your calculation. For example:

measure=var selectedDate=MAX('date'[date])

return CALCULATE('your_expression', DATESBETWEEN('date'[date],"01.04.2020",selectedDate))

View solution in original post

Hi @Anonymous 

The MAX function only accepts a column reference as an argument.
it's giving error like.

View solution in original post

Anonymous
Not applicable

@sarjensystems1 Then you need something like this:

measure=var selectedDate=MAX('date'[date])

return CALCULATE('your_expression', DATESBETWEEN('date'[date],selectedDate+30,selectedDate+60))

 

That is, you can add to selected date any number of days that's needed.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

@sarjensystems1 If you have proper date table you can use DATESBETWEEN as filter for your calculation. For example:

measure=var selectedDate=MAX('date'[date])

return CALCULATE('your_expression', DATESBETWEEN('date'[date],"01.04.2020",selectedDate))

hi @Anonymous 

Same I want to calculate after data for selected date, for that Should i Use today function ? replacing '01-04-2021'

Anonymous
Not applicable

@sarjensystems1 If you want to calculate for period from today to selected date then yes, you should use TODAY function instead of "01.04.2021". But if you want to calculate for period from selected date to the last date in your dataset then measure should look like this:

 

measure=var selectedDate=MAX('date'[date])

var maxDate=MAX(ALL('date'[date]))

return CALCULATE('your_expression', DATESBETWEEN('date'[date],selectedDate,maxDate))

hi @Anonymous 

Thanks for your efforts, one last dax i am looking for is that , can we calculate data from selected date till next 30 days. ("0-30days") and same for "31-60 days".

As you can see, I want to calculate from selected date to next 30 days, 31- next 60 days and so on.

Screenshot (261).png

Anonymous
Not applicable

@sarjensystems1 Then you need something like this:

measure=var selectedDate=MAX('date'[date])

return CALCULATE('your_expression', DATESBETWEEN('date'[date],selectedDate+30,selectedDate+60))

 

That is, you can add to selected date any number of days that's needed.

Hi @Anonymous 

The MAX function only accepts a column reference as an argument.
it's giving error like.

Anonymous
Not applicable

@sarjensystems1 That's right, my bad:(

That variable should be like this:

var maxDate=MAXX(ALL('date'[date]), 'date'[date])

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors