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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Kaushik2020
Creator III
Creator III

Number formatting not working

I am calculating MTD and LMTD using below expressions: 

MTD:- 

Num(Avg(Aggr(((count({$<Year=, Month=, Day=,
Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>}
distinct Txt_IssueID))

/

((Count({$<Year=, Month=, Day=,
Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>}
Distinct LAST_MODIFIED_BY)))),Day)),'#0') -- results 5

 

LMTD:-

Num(Avg(Aggr(((count({$<Year=, Month=, Day=,
Date={">=$(=date(monthstart(max(Date),-1)))<=$(=date(addmonths(max(Date),-1)))"}>}
distinct Txt_IssueID))

/

((Count({$<Year=, Month=, Day=,
Date={">=$(=date(monthstart(max(Date),-1)))<=$(=date(addmonths(max(Date),-1)))"}>}
Distinct LAST_MODIFIED_BY)))),Day)),'#0') --results 5 

 

When I am calculating variance for these 2 numbers with below expression i am getting -6% instead of 0.

 

NUM ((Num(Avg(Aggr(((count({$<Year=, Month=, Day=,
Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>}
distinct Txt_IssueID))

/

((Count({$<Year=, Month=, Day=,
Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>}
Distinct LAST_MODIFIED_BY)))),Day)),'#0'))


/

(Num(Avg(Aggr(((count({$<Year=, Month=, Day=,
Date={">=$(=date(monthstart(max(Date),-1)))<=$(=date(addmonths(max(Date),-1)))"}>}
distinct Txt_IssueID))

/

((Count({$<Year=, Month=, Day=,
Date={">=$(=date(monthstart(max(Date),-1)))<=$(=date(addmonths(max(Date),-1)))"}>}
Distinct LAST_MODIFIED_BY)))),Day)),'#0'))-1,
CHR(9650)&'#,##0%;'&CHR(9660)&'#,##0%')

//Tried using number formatting as Auto and Measure expression.

Expectation is 0.

Please suggest.

Labels (6)
1 Solution

Accepted Solutions
Chirantha
Support
Support

 Hello Kaushi,

 

When you use the Num() function with a number format like '#0', Qlik Sense rounds the number to the nearest integer before performing any further calculations. This could be causing the unexpected -6% result in your variance calculation, even though the MTD and LMTD values appear to be the same.

One possible solution could be to move the Num() function outside of your set analysis expressions and apply it only after you’ve calculated the variance. Here’s an example:

Variance:-
NUM (
   (
       Avg(Aggr(((count({$<Year=, Month=, Day=, Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>} distinct Txt_IssueID)) / (Count({$<Year=, Month=, Day=, Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>} Distinct LAST_MODIFIED_BY)))),Day))
       /
       Avg(Aggr(((count({$<Year=, Month=, Day=, Date={">=$(=date(monthstart(max(Date),-1)))<=$(=date(addmonths(max(Date),-1)))"}>} distinct Txt_IssueID)) / (Count({$<Year=, Month=, Day=, Date={">=$(=date(monthstart(max(Date),-1)))<=$(=date(addmonths(max(Date),-1)))"}>} Distinct LAST_MODIFIED_BY)))),Day))
   ) - 1,
   CHR(9650)&'#,##0%;'&CHR(9660)&'#,##0%'
)
 

View solution in original post

1 Reply
Chirantha
Support
Support

 Hello Kaushi,

 

When you use the Num() function with a number format like '#0', Qlik Sense rounds the number to the nearest integer before performing any further calculations. This could be causing the unexpected -6% result in your variance calculation, even though the MTD and LMTD values appear to be the same.

One possible solution could be to move the Num() function outside of your set analysis expressions and apply it only after you’ve calculated the variance. Here’s an example:

Variance:-
NUM (
   (
       Avg(Aggr(((count({$<Year=, Month=, Day=, Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>} distinct Txt_IssueID)) / (Count({$<Year=, Month=, Day=, Date={">=$(=date(monthstart(max(Date))))<=$(=date(max(Date)))"}>} Distinct LAST_MODIFIED_BY)))),Day))
       /
       Avg(Aggr(((count({$<Year=, Month=, Day=, Date={">=$(=date(monthstart(max(Date),-1)))<=$(=date(addmonths(max(Date),-1)))"}>} distinct Txt_IssueID)) / (Count({$<Year=, Month=, Day=, Date={">=$(=date(monthstart(max(Date),-1)))<=$(=date(addmonths(max(Date),-1)))"}>} Distinct LAST_MODIFIED_BY)))),Day))
   ) - 1,
   CHR(9650)&'#,##0%;'&CHR(9660)&'#,##0%'
)