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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
GarethWoodhouse
Resolver I
Resolver I

DAX to Calculate SUM where one date is higher than another

Evening PowerBI people.

I am in need of some DAX assistance.

 

I have created a table called TodaysDate that hols todays date plus a measure to calculate 3 months back.

 

I have then written the below DAX in another table to Sum "Revenue" but only where the Date "Financial Period" > 3 months back

 

Total Revenue = calculate(SUM('Ex SP Figures'[Revenue]),'Ex SP Figures'[Financial Period]>TodaysDate[3monthsback])
 
The problem is the Calculate finction is complaining it's being used on a True/False Expression that is used as a table expression.
 
What am I doing wrong?
 
Many Thanks in advance.

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

You cannot use two columns in the calculate statement. These should work

 

Total Revenue = 
VAR d = MAX(TodaysDate[3monthsback]) 

RETURN
SUMX(
  FILTER(
    'Ex SP Figures',
    'Ex SP Figures'[Financial Period] > d
  ),
  'Ex SP Figures'[Revenue]
)
Total Revenue = 
calculate(
  SUM('Ex SP Figures'[Revenue]),
  FILTER(
    'Ex SP Figures'[Financial Period],
    'Ex SP Figures'[Financial Period]>MAX(TodaysDate[3monthsback])
  )
)

 

View solution in original post

3 REPLIES 3
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @GarethWoodhouse,

 

Could you please mark the proper answers as solutions?

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

You cannot use two columns in the calculate statement. These should work

 

Total Revenue = 
VAR d = MAX(TodaysDate[3monthsback]) 

RETURN
SUMX(
  FILTER(
    'Ex SP Figures',
    'Ex SP Figures'[Financial Period] > d
  ),
  'Ex SP Figures'[Revenue]
)
Total Revenue = 
calculate(
  SUM('Ex SP Figures'[Revenue]),
  FILTER(
    'Ex SP Figures'[Financial Period],
    'Ex SP Figures'[Financial Period]>MAX(TodaysDate[3monthsback])
  )
)

 

TomMartens
Super User
Super User

Hey,

 

please have a look at this site:

https://www.daxpatterns.com/time-patterns/

 

I guess, here you will your answer.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors