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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
karandeep
Contributor II
Contributor II

Formula change based on the Filter pan Selection

Hi there, 

I’m working with a product selection filter in QlikApp, and I need the Profit Percentage calculation to adjust dynamically based on the selected product.

  • If Product A is selected, Profit % should be calculated based on Sales.

  • If Product B is selected, Profit % should be calculated based on Cost.

What formula can I use to ensure the calculation updates accordingly based on the selection in 'Filter Pan'?

Could you please help, Many thanks!

Product  Sales Cost Proft Profit%
A £500 £200 £300 ?
B £400 £100 £300 ?
Labels (1)
1 Solution

Accepted Solutions
Chanty4u
MVP
MVP

Try this 

=Pick(

  Match(Only(Product), 'A', 'B'),

  Sum(Profit) / Sum(Sales),

  Sum(Profit) / Sum(Cost

)

)

Or 

=IF(

  GetSelectedCount(Product) = 1,

  IF(

    Only(Product) = 'A',

    Sum(Profit) / Sum(Sales),

    IF(Only(Product) = 'B',

      Sum(Profit) / Sum(Cost)

   

)

  )

)

View solution in original post

1 Reply
Chanty4u
MVP
MVP

Try this 

=Pick(

  Match(Only(Product), 'A', 'B'),

  Sum(Profit) / Sum(Sales),

  Sum(Profit) / Sum(Cost

)

)

Or 

=IF(

  GetSelectedCount(Product) = 1,

  IF(

    Only(Product) = 'A',

    Sum(Profit) / Sum(Sales),

    IF(Only(Product) = 'B',

      Sum(Profit) / Sum(Cost)

   

)

  )

)