cancel
Showing results for
Did you mean:
Highlighted
Frequent Visitor

## Date formula All values to a max date?

Is there a function to calculate all values up to a filtered date?

Something like

Total Qty quoted alltime = CALCULATE (
SUMX (quotation_data_tab,[Qty] ),
FILTER (
ALL ( quotation_data_tab[bi_sd_so_order_date]),
quotation_data_tab[bi_sd_so_order_date]<= MAX (quotation_data_tab[bi_sd_so_order_date])
)
)

But where the date filter applied only applies to the maximum date and includes all lesser dates.

If I apply a filter to the view (ie March 2018) I only get the result for that selection, not all prior date values?

Help appreciated
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team

## Re: Date formula All values to a max date?

Hi @KarlNixon,

If there is relationship between data table and the fact tabel, once you choose any value in the slicer. Then the fact table will be filterd accrodingly. Then you cannot get the result as you want in the table visual. However for the value in the card, we can use ALL function to ignore the filer. So we can update the measure as below to work on it.

`Measure 2 = CALCULATE(SUM(Table1[qty]),FILTER(ALL(Table1),Table1[date]<=MAX('CALENDAR'[Date])))`

For more detaills, please check the pbix as attacched.

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
5 REPLIES 5
Community Support Team

## Re: Date formula All values to a max date?

Hi @KarlNixon,

1. Create a CALENDAR table and create a calculated column in it.

`CALENDAR = CALENDARAUTO()`
`Yearmonth = FORMAT('CALENDAR'[Date],"yyyymmm")`

2. Create the measures as below.

```Measure = var maxdt = MAX('Table1'[date])
var maxdc = MAX('CALENDAR'[Date])
return
IF(maxdc>=maxdt,1,0)
```
`Measure 2 = CALCULATE(SUM(Table1[qty]),FILTER(Table1,Table1[date]<=MAX('CALENDAR'[Date])))`

Please filter the table visual by the measure as the picture as below.

For more details, please check the pbix as attached.

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Super User

## Re: Date formula All values to a max date?

Hi,

Ensure you have a Calendar Table with a relationship from the Date column of the quotation_data_tab Table to the Date column of the Calendar Table.  Drag the Dates from the Calendar Table to the slicer.  Write this measure

=CALCULATE([Qty],DATESBETWEEN(Calendar[Date],MINX(ALL(Calendar),Calendar[Date]),MAX(Calendar[Date]))

Hope this helps.

Frequent Visitor

## Re: Date formula All values to a max date?

Hi Frank,

It looks like the solution won't work if there is a relationship between the Table1[Date] field and the Calander[Date] field

I'm perplexed as to why?

Karl

Community Support Team

## Re: Date formula All values to a max date?

Hi @KarlNixon,

If there is relationship between data table and the fact tabel, once you choose any value in the slicer. Then the fact table will be filterd accrodingly. Then you cannot get the result as you want in the table visual. However for the value in the card, we can use ALL function to ignore the filer. So we can update the measure as below to work on it.

`Measure 2 = CALCULATE(SUM(Table1[qty]),FILTER(ALL(Table1),Table1[date]<=MAX('CALENDAR'[Date])))`

For more detaills, please check the pbix as attacched.

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Frequent Visitor

## Re: Date formula All values to a max date?

Thanks for your help Frank - all solved!

Announcements

#### Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

#### Community News & Announcements

Get your latest community news and announcements.

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 287 members 2,622 guests
Recent signins: