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
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
Kristjan76
Responsive Resident
Responsive Resident

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
Employee
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.
Kristjan76
Responsive Resident
Responsive Resident

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