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

How do I create a sum based on a condition?

Hi

I'm really hoping someone can help me.  I am trying to create a sum which adds up all of the [Actual cost] and the [Estimated cost] ( if the [Actual cost] has a figure in it) for last month. 

This is what I have come up with but it doesn't seem to be working and I don't know where I am going wrong. 

Expression

(Sum({<[Date]={">=01/12/2022<=31/12/2022"}>}[Actual Value]))
+
(Sum({<[Actual Value]=NULL,[Date]={">=01/12/2022<=31/12/2022"}>}[Estimated Value]))

Current results

louise_atherton_0-1673254045575.png

As you can see when I try and create the total value sum it pulls through the [Actual Value] but not the [Estimated Value] if [Actual Value] is blank.  

As always, any help would be gratefully received. 

 

Many thanks

 

Louise 

Labels (1)
4 Replies
BrunPierre
Partner - Master

Maybe like this?

(Sum({<[Date]={">=01/12/2022<=31/12/2022"}>}[Actual Value]))
+
(Sum({<[Actual Value]={">0"},[Date]={">=01/12/2022<=31/12/2022"}>}[Estimated Value]))

louise_atherton
Contributor III
Author

Hiya

Thanks for taking the time to try and help. Unfortunately that doesn't work as this is now adding the 2 fields together where both have information and not including estimate where actual is 0. 

louise_atherton_0-1673258373859.png

 

 

 

ogster1974
Partner - Master II

slight tweak.

(Sum({<[Actual Value]={">0"},[Date]={">=01/12/2022<=31/12/2022"}>}[Actual Value]))
+
(Sum({<[Actual Value]={"=0"},[Date]={">=01/12/2022<=31/12/2022"}>}[Estimated Value]))

Bhuvi
Partner - Contributor III

Try this

(Sum({<[Date]={">=01/12/2022<=31/12/2022"}>}[Actual Value]))
+
(Sum({<[Date]={">=01/12/2022<=31/12/2022"}>}[Estimated Value]))

remove the Null condition and check