Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
GDunn1
Contributor III
Contributor III

Subtracting latest month from prior month value

I want to create a sum to minus the latest month from the prior month. Then change the answer to the millions number format. This expression does not cause an error, but does return 0 values;

num (sum( {<MonthKey={'$(=max(MonthKey)))'} >}ClosingFUA ) - (sum( {<MonthKey={'$(=max(MonthKey)-1))'} >}ClosingFUA )) /1000000, '#,##0.00 M')

Labels (1)
1 Solution

Accepted Solutions
Lisa_P
Employee
Employee

Sorry, I didn't remove the extra brackets ..

num (
              (sum( {<MonthKey={'$(=max(MonthKey))'} >}ClosingFUA )
               - sum( {<MonthKey={'$(=max(MonthKey)-1)
'} >}ClosingFUA ))
               /1000000
          , '#,##0.0 M')

View solution in original post

6 Replies
Lisa_P
Employee
Employee

Your expression has too many closing brackets ..

num (sum( {<MonthKey={'$(=max(MonthKey)))'} >}ClosingFUA ) - (sum( {<MonthKey={'$(=max(MonthKey)-1))'} >}ClosingFUA )) /1000000, '#,##0.00 M')

 

GDunn1
Contributor III
Contributor III
Author

Thanks @Lisa_P , removing these brackets returns the value but the number format is the full number and M (12,345,678.90 M) rather than the 12.3 M format required.

Lisa_P
Employee
Employee

Ok, try this:

num (
              (sum( {<MonthKey={'$(=max(MonthKey)))'} >}ClosingFUA )
               - sum( {<MonthKey={'$(=max(MonthKey)-1)
)'} >}ClosingFUA ))
               /1000000
          , '#,##0.0 M')

GDunn1
Contributor III
Contributor III
Author

Thanks @Lisa_P , but this returns zero for each line item

Lisa_P
Employee
Employee

Sorry, I didn't remove the extra brackets ..

num (
              (sum( {<MonthKey={'$(=max(MonthKey))'} >}ClosingFUA )
               - sum( {<MonthKey={'$(=max(MonthKey)-1)
'} >}ClosingFUA ))
               /1000000
          , '#,##0.0 M')

GDunn1
Contributor III
Contributor III
Author

Excellent, thank you @Lisa_P . Perfect