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: 
ngetal_93
Partner - Contributor II
Partner - Contributor II

Share of most frequent value in a field by a dimension

Hello all!

I am trying to get the share of the most used  "notif_mode_of_operation_description" in my list of " key_notificationno " and this by "Plant Description" in my table.

ngetal_93_1-1742467507335.png

While the Mode(notif_mode_of_operation_description) column and the count( key_notificationno ) are giving expected results, the middle one seems not to give expected results, here is the current formula :

count( {<notif_mode_of_operation_description={$(=Mode(notif_mode_of_operation_description))}>} key_notificationno) 

Instead of showing the result of the mode of the line itself, it shows the result for the whole selection (Maintenance in our case), ignoring the Plant Description it is supposed to refer to...  ( First line is ok because the "mode" is Maintenance as well but second line should show something close to 10000 if it was taking the right value)

I tried many things always coming to this result, am I missing something?

Thanks,

Labels (2)
2 Solutions

Accepted Solutions
marcus_sommer

It's not solvable with a set analysis else it needs an if-loop to consider the dimensionality of the object, like:

if(notif_mode_of_operation_description =       
    Mode(notif_mode_of_operation_description),
count(key_notificationno))

View solution in original post

ngetal_93
Partner - Contributor II
Partner - Contributor II
Author

Hello Marcus,

Thanks, it guided me towards correct answer : what ended up working was : 

sum(aggr(
if(notif_mode_of_operation_description =
Mode(total<[Plant Description]> notif_mode_of_operation_description),
count(key_notificationno))
,[Plant Description],key_notificationno))

ngetal_93_0-1742827341419.png

 

View solution in original post

6 Replies
Chanty4u
MVP
MVP

Try this 

Count({<notif_mode_of_operation_description = {$(=Mode(Aggr(notif_mode_of_operation_description, [Plant Description])))}>} key_notificationno)

 

ngetal_93
Partner - Contributor II
Partner - Contributor II
Author

Thanks for your answer! sadly it did not work (showing 0 as result), I tried as well with Mode inside of aggr but same result... any other idea? 

Chanty4u
MVP
MVP

Try this 

Count({<notif_mode_of_operation_description = {"=$(=Mode(Aggr(notif_mode_of_operation_description, [Plant Description])))"}>} key_notificationno)

 

ngetal_93
Partner - Contributor II
Partner - Contributor II
Author

Hello, it still gives 0 ...  I tried many things with the AGGR, most of them gives 0, and when it does not, it comes back to initial result, as if "Maintenance" was most frequent for all plants. 

Funny thing : 

count( {<notif_mode_of_operation_description={"$(=maxstring(Aggr(mode(notif_mode_of_operation_description), [Plant Description])))"}>} key_notificationno)  

gives as if "Maintenance" is the most common for all plants and place it for all, and 

count( {<notif_mode_of_operation_description={"$(=minstring(Aggr(mode(notif_mode_of_operation_description), [Plant Description])))"}>} key_notificationno)

gives as if "In service - Manual Driving" was the most common for all plant and applies its value. So I know both values are captured, I just can't manage to single them line by line (plant by plant)

marcus_sommer

It's not solvable with a set analysis else it needs an if-loop to consider the dimensionality of the object, like:

if(notif_mode_of_operation_description =       
    Mode(notif_mode_of_operation_description),
count(key_notificationno))

ngetal_93
Partner - Contributor II
Partner - Contributor II
Author

Hello Marcus,

Thanks, it guided me towards correct answer : what ended up working was : 

sum(aggr(
if(notif_mode_of_operation_description =
Mode(total<[Plant Description]> notif_mode_of_operation_description),
count(key_notificationno))
,[Plant Description],key_notificationno))

ngetal_93_0-1742827341419.png