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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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