Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional SUM

Good Evening,

I'm, trying to do something like that:

=Sum(if(MovementType='Sales' and Year(Date)=Max(Year(Date)),Sales))

MovementType = it's to identify the type of Fact

I want to Sum the sales of the current year in the selection and the previous year.

Can you show me why this is not working but the expression says ok?

Best Regards,

Ricardo Perfeito

1 Solution

Accepted Solutions
Not applicable
Author

Thank you all for showing me the way!!!.

Yuri:

Your expression is missing one )


Sum({< MovementType= {"Sales"}, Year={'$(=Max(Year(Date)))'}>} Sales)


However i made a different approach and i want to share with you.

I have a master calendar, so i don't need to add a column in my fact table. The Year is a column that i have in my master calendar table. I link the fact table through the column Date to the master calendar.


What do you think about this solution?

Awesome forum!!!

Best Regards,


Ricardo Perfeito


View solution in original post

3 Replies
nicolett_yuri

Try it,


Sum({< MovementType= {"Sales"}, Year={'$(=Max(Year(Date))'}>} Sales)


Create a column with a Year of date.

jduenyas
Specialist
Specialist

The reply by Yuri as correct.

Here though is the explanation:

Your expression is correct (there are no gramatical errors in it)  so it wil say that the expression is OK.

However, you are not selecting a Year you are only comparing one function's value to another function's value

Year(Date)=Max(Year(Date))

It should be Year =Max(Year(Date)), where Year is a selectable column.

your table should look something like this:

MovementTypeYearSales
Sales2012100
Purchase2012200
Purchase2013150
Sales2013250
Sales2013300
Purchase2013450
Not applicable
Author

Thank you all for showing me the way!!!.

Yuri:

Your expression is missing one )


Sum({< MovementType= {"Sales"}, Year={'$(=Max(Year(Date)))'}>} Sales)


However i made a different approach and i want to share with you.

I have a master calendar, so i don't need to add a column in my fact table. The Year is a column that i have in my master calendar table. I link the fact table through the column Date to the master calendar.


What do you think about this solution?

Awesome forum!!!

Best Regards,


Ricardo Perfeito