cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
KarlNixon Frequent Visitor
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])
)
)
 
 
cumulative example.JPG
 
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?
 
cumulative example 2.JPG
 
Help appreciated Smiley Wink
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
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.

View solution in original post

5 REPLIES 5
Community Support Team
Community Support Team

Re: Date formula All values to a max date?

Hi @KarlNixon,

 

I made one sample for your referece. Please check the following steps as below.

 

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. 

Capture.PNG

 

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
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.

KarlNixon Frequent Visitor
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
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.

View solution in original post

KarlNixon Frequent Visitor
Frequent Visitor

Re: Date formula All values to a max date?

Thanks for your help Frank - all solved!

 

 

 

 

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

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

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

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.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

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

Users Online
Currently online: 287 members 2,622 guests
Please welcome our newest community members: