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
WillemC
Resolver I
Resolver I

Calculate SUM for last period: FILTER creates Blank

Hi all,

 

I want to create a sum of weight for this year (till today) and compare it with a sum of weight for the exact same period last year.

I've created a New Measure as follow (-1;year doesn't work either and changing the order of year=2017 vs the date part doesn't do a thin either):

2017weight = 
CALCULATE(SUM('ds1'[Weight]);FILTER(ds1;'ds1'[levdat] < dateadd(ds1[today];-12;MONTH));('ds1'[year]=2017))

in the dateadd, [today] is a new measure containing (won't accept today() in a dateadd as everyone is familiar with):

 

today = today()

The above field 2017weight results in a 'Blank' field.

Why is that?

 

The following code does work, but it takes the whole month which I don't want.

2017weight = 
CALCULATE(SUM('ds1'[Weight]);('ds1'[year]=2017);ds1[month]<=month(today()))

Any thoughts?

1 ACCEPTED SOLUTION
WillemC
Resolver I
Resolver I

Okay, seems lik I found a solution by coincidence (have to re-calculate the result, but seems okay).

 

2017weight = 
CALCULATE(SUM('ds1'[Weight]);('ds1'[year]=2017);('ds1'[levdat]<Date(year(now())-1;month(now());day(now()))))

really can't wrap my head around why this does work, and my previous attempt not.

What's the reason the dateadd won't work, as this dateadd function is explicit for this kind of calculation.

 

In my opinion my fix here is another way of writing what a dateadd function should do.

View solution in original post

1 REPLY 1
WillemC
Resolver I
Resolver I

Okay, seems lik I found a solution by coincidence (have to re-calculate the result, but seems okay).

 

2017weight = 
CALCULATE(SUM('ds1'[Weight]);('ds1'[year]=2017);('ds1'[levdat]<Date(year(now())-1;month(now());day(now()))))

really can't wrap my head around why this does work, and my previous attempt not.

What's the reason the dateadd won't work, as this dateadd function is explicit for this kind of calculation.

 

In my opinion my fix here is another way of writing what a dateadd function should do.

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.