# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today. Not applicable

## Min Max function

Good morning everyone,

I am new in Qlik Sense and I would like to reproduce a formula from Excel in my Qlik Sense script

The formula I am trying to edit from Excel is =MIN(MAX((A1-B2)/B2),1)

Where A1 in Qlik is (Sum({<CurYTDFlag={1}, Year={\$(=Year(\$(vMaxDate)))}>}[TR])

and B2 in Qlik is (Sum([MC])*max({<TRYTDFlag={1} >}[Quota]))

Thank you

Marie

3 Replies
Honored Contributor

## Re: Min Max function

Hi Marie,

You can see at least a little bit the source data, and that you want to get as a result?

Regards,

Andrey Not applicable

## Re: Min Max function

Hello Andrey,

A1 is represents revenue (TR) and B2 is represents the costs (MC). The formula in Excel returns an amount between -1 and 1 (that is why we have MAX and MIN). The YTD Flags are fixing the amounts in the current year, both A1 and B2 in Qlik Sense are returning correct results, the error appears when I try to include the Min and Max functions.

I don’t have a qvs file, but for example, if A1 is 150 and B2 is 40, the formula will bring 1.

If A1 is 60 and B2 is 80, the formula will bring 0.25.

I hope it helps.

Thanks again

Marie MVP

## Re: Min Max function

I am just assuming Your Value

If A1 Gives 100 and B2 gives 20 then your formula seems this

=MIN(MAX((A1-B2)/B2),1)

Max((100-50)/50) -- Max(50/50) -- Max(1) -- 1

Min(1, 1) -- 1 Only , Here what was the logic behind this. I doubt i am follow you or not 100% Accuracy. Would you describe more

Life is so rich, and we need to respect to the life !!!
Community Browser