Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Louveduval
Creator
Creator

Num fonction

I'm sorry it's a very stupid question.  
I want have the difference between  [Taux marge théorique : mai-2023] and  [Taux marge théorique : mai-2022]  in point . 

if([MARGE - Taux marge mois max A-1]<[MARGE - Taux marge mois max],
          Fabs(([MARGE - Taux marge mois max A-1]-[MARGE - Taux marge mois max])*100),
                   ([MARGE - Taux marge mois max A-1]-[MARGE - Taux marge mois max])*100)
                & '  pts'

Louveduval_1-1683876741413.png

but it's too long , I can't  have 3,73 due to the fact that I ve put & '  pts' 

So I've try  to use the num() fonction but it's making a rounding 

if([MARGE - Taux marge mois max A-1]<[MARGE - Taux marge mois max],
num((Fabs(([MARGE - Taux marge mois max A-1]-[MARGE - Taux marge mois max])*100)),'0.00',','),
        ([MARGE - Taux marge mois max A-1]-[MARGE - Taux marge mois max])*100)
                & '  pts'

Louveduval_0-1683876520466.png

Can you help me ? 

Best regard 

Labels (3)
1 Solution

Accepted Solutions
Louveduval
Creator
Creator
Author

Finally 
I ve made something very simple 

Louveduval_0-1686237619480.png

 

View solution in original post

4 Replies
Chanty4u
MVP
MVP

May be you can try this 

if([MARGE - Taux marge mois max A-1] < [MARGE - Taux marge mois max],

    Num(Abs(([MARGE - Taux marge mois max A-1] - [MARGE - Taux marge mois max]) * 100), '0.00') & ' pts',

    Num(([MARGE - Taux marge mois max A-1] - [MARGE - Taux marge mois max]) * 100, '0.00') & ' pts'

 

)

Louveduval
Creator
Creator
Author

sadly it's does't work 

 

Louveduval_0-1683881481983.png

 

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @Louveduval

I think the only issue in @Chanty4u's expression is that abs should be fabs:

if([MARGE - Taux marge mois max A-1] < [MARGE - Taux marge mois max],
    Num(fabs(([MARGE - Taux marge mois max A-1] - [MARGE - Taux marge mois max]) * 100), '0.00') & ' pts',
    Num(([MARGE - Taux marge mois max A-1] - [MARGE - Taux marge mois max]) * 100, '0.00') & ' pts')

I might be missing something, but I think that you can simplify all of that into:

 Num(fabs(([MARGE - Taux marge mois max A-1] - [MARGE - Taux marge mois max]) * 100), '0.00') & ' pts'

As you are first checking whether it is going to give you a positive or negative answer, and then converting to positive if it is negative. The fabs function will leave positive values as positive, so it is quite safe to use regardless of which value is largest.

The other thing to note is that that function returns text, which will not sort correctly and could behave a bit odd if you have it in a table. You might therefore want to use a dual function, so that it sorts correctly numerically but looks correct in the KPI also:

Dual(
Num(fabs(([MARGE - Taux marge mois max A-1] - [MARGE - Taux marge mois max]) * 100), '0.00') & ' pts',
[MARGE - Taux marge mois max A-1] - [MARGE - Taux marge mois max])

Hope that helps.

Steve

https://www.quickintelligence.co.uk/blog/

Louveduval
Creator
Creator
Author

Finally 
I ve made something very simple 

Louveduval_0-1686237619480.png