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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nkillia
Frequent Visitor

Issue using Date measure to filter a summing measure

I have created a Start Date measure to calculate the latest start date:

 

Start_Date.png

 

I am trying to use this date measure to filter data for a summing measure:

CALCULATE(
SUM(Data[Amount]),
FILTER(Data,Data[Date] >= [Start Date]))

 This measure is returning the Sum of the amount from all years.

CALCULATE(
SUM(Data[Amount]),
FILTER(Data,Data[Date] >=DATE(2019,1,1))
 
This version of the measure is returning the correct amount. 
 
Is there a way to filter the data using a Date measure?
 
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @nkillia 
 
Modify your MAX_Date measure as below
 
MAX_Date = CALCULATE(MAX(TEST1[Date]),FILTER(all(TEST1),TEST1[Type]<>"B")).
 
 when we add "all" it takes your entire dataset irrespective of your filters.
PReviously we are simple checking with it with filters and it is evaluating  MAX Date for each row. 
 
 
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

View solution in original post

10 REPLIES 10
v-easonf-msft
Community Support
Community Support

Hi ,@nkillia 

According to you description,  you can try to  add “all” function in you  your measures “Max Current Date” .

I don't have the formula of your measure “Max Current Date” .

So  here is  a simple sample  using some  other data:

c.png

 

Max Current Date = CALCULATE(MAX(financials[Date].[Date]),all(financials))
Max Current Date without all = MAX(financials[Date])

By comparison ,you will find the measure “Max Current Date” ignore any filters that might have been applied  .

 

If it doesn't meet your requirement, kindly share your sample data and expected result if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

 

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

Hi @v-easonf-msft ,

 

Here is an example of what I am hoping to acomplish:
My MAX Date Formula is =Max('table'[Date])
My Start Date Formula is = Date(YEAR([Max Date]),1,1)
I am trying to sum only the data that has a date greater than 1/1/2019

 

Example.png

Anonymous
Not applicable

Hi @nkillia 

 

Try this,

 

CALCULATE(SUM(Customer[Sales]),FILTER(Customer,Customer[Monthly].[Year]>=YEAR(MAX(Customer[Monthly]))))
 
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

Hi @Anonymous ,

 

Thank you, is there a way to use the start date measure instead of YEAR(MAX(Customer[Monthly])) part?

Anonymous
Not applicable

Hi @nkillia 

 

Modify your measure

 

start date measure=YEAR(MAX(Customer[Monthly])) 

 

and use this measure in your filter part of formula .

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

 

 

This may be a better example of what I am trying to accomplish.

 

1. Return the max date of type A
        Max A Date =CALCULATE(MAX('Table'[Date]),'Table'[Type] <> "B")

2. Return start of the year for that date.

       A Start Year = DATE(Year([Max A Date]),1,1)

 

3. Return sum of the amount between those two dates excluding type B

Sum of Amount = CALCULATE(SUM('Table'[Amount]),'Table'[Type]<>"B",FILTER('Table', ('Table'[Date] >= [A Start Year] && 'Table'[Date] <= [Max A Date])))
 
This should be returning 10 but is returning 22.

Example.png

 

The test data can be found below:

Date         Amount Type

1/1/20181A
2/1/20181A
3/1/20181A
4/1/20181A
5/1/20181A
6/1/20181A
7/1/20181A
8/1/20181A
9/1/20181A
10/1/20181A
11/1/20181A
12/1/20181A
1/1/20191A
2/1/20191A
3/1/20191A
4/1/20191A
5/1/20191A
6/1/20191A
7/1/20191A
8/1/20191A
9/1/20191A
10/1/20191A
1/1/20191B
2/1/20191B
3/1/20191B
4/1/20191B
5/1/20191B
6/1/20191B
7/1/20191B
8/1/20191B
9/1/20191B
10/1/20191B
11/1/20191B
12/1/20191B
1/1/20201B
2/1/20201B
3/1/20201B
4/1/20201B
5/1/20201B
6/1/20201B
7/1/20201B
8/1/20201B
9/1/20201B
10/1/20201B
11/1/20201B
12/1/20201B

 

Anonymous
Not applicable

Hi @nkillia 
 
Modify your MAX_Date measure as below
 
MAX_Date = CALCULATE(MAX(TEST1[Date]),FILTER(all(TEST1),TEST1[Type]<>"B")).
 
 when we add "all" it takes your entire dataset irrespective of your filters.
PReviously we are simple checking with it with filters and it is evaluating  MAX Date for each row. 
 
 
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

@Anonymous Thank you, I believe that worked for me. 
Thank you again for all your time and effort. I truly appreciate it. 

az38
Community Champion
Community Champion

@nkillia 

try

CALCULATE(
SUM(Data[Amount]),
FILTER(ALL(Data),Data[Date] >= SELECTEDVALUE([Start Date])))

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
nkillia
Frequent Visitor

Hi @az38,

 

I tried the following and received this error: "Column 'Start Date' cannot be found or may not be used in this expression"

Is there any expression that would be able to grab the value of the measure?  

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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