<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic MODE Formula in Incorta in Dashboards &amp; Analytics Discussions</title>
    <link>https://community.incorta.com/t5/dashboards-analytics-discussions/mode-formula-in-incorta/m-p/3897#M338</link>
    <description>&lt;P&gt;I there a quick way to enact a Mode formula in Incorta to show the most common value within a measure array?&lt;/P&gt;</description>
    <pubDate>Wed, 15 Mar 2023 00:11:08 GMT</pubDate>
    <dc:creator>msamuels5</dc:creator>
    <dc:date>2023-03-15T00:11:08Z</dc:date>
    <item>
      <title>MODE Formula in Incorta</title>
      <link>https://community.incorta.com/t5/dashboards-analytics-discussions/mode-formula-in-incorta/m-p/3897#M338</link>
      <description>&lt;P&gt;I there a quick way to enact a Mode formula in Incorta to show the most common value within a measure array?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 00:11:08 GMT</pubDate>
      <guid>https://community.incorta.com/t5/dashboards-analytics-discussions/mode-formula-in-incorta/m-p/3897#M338</guid>
      <dc:creator>msamuels5</dc:creator>
      <dc:date>2023-03-15T00:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: MODE Formula in Incorta</title>
      <link>https://community.incorta.com/t5/dashboards-analytics-discussions/mode-formula-in-incorta/m-p/3898#M339</link>
      <description>&lt;P&gt;&lt;a href="https://community.incorta.com/t5/user/viewprofilepage/user-id/223"&gt;@msamuels5&lt;/a&gt;&amp;nbsp;-&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you probably found, there isn't an aggregate method in Incorta that supports this. A few ways you could try are:&lt;BR /&gt;1) Leveraging insights over results or a SQL view to count occurrences of data and rank the results.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Leverage a MV and import the python statistics package&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;statistics.mode(measure)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 01:00:00 GMT</pubDate>
      <guid>https://community.incorta.com/t5/dashboards-analytics-discussions/mode-formula-in-incorta/m-p/3898#M339</guid>
      <dc:creator>JoeM</dc:creator>
      <dc:date>2023-03-15T01:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: MODE Formula in Incorta</title>
      <link>https://community.incorta.com/t5/dashboards-analytics-discussions/mode-formula-in-incorta/m-p/3911#M342</link>
      <description>&lt;P&gt;Thanks Joe, yes I need this at an aggregate level. Unfortunately I don't construct MV's as well as not versed in Python.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 19:46:17 GMT</pubDate>
      <guid>https://community.incorta.com/t5/dashboards-analytics-discussions/mode-formula-in-incorta/m-p/3911#M342</guid>
      <dc:creator>msamuels5</dc:creator>
      <dc:date>2023-03-16T19:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: MODE Formula in Incorta</title>
      <link>https://community.incorta.com/t5/dashboards-analytics-discussions/mode-formula-in-incorta/m-p/3928#M343</link>
      <description>&lt;P&gt;Hi MSAMUEL,&lt;/P&gt;&lt;P&gt;Ill preface this by offering hands on assistance if needed.&lt;/P&gt;&lt;P&gt;To clarify the problem, essentially we want the value with the most occurrences within a field.&lt;/P&gt;&lt;P&gt;To expand upon Joes response you can derive this quite easily with SQL in an Incorta Materialized view, I want to illustrate this for you with the following example(s):&lt;/P&gt;&lt;P&gt;We have a table SalesOrderDetails which includes a field 'UnitPrice'&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZachBreimayer_0-1679086882273.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2010iD64CFD3165A697D9/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ZachBreimayer_0-1679086882273.png" alt="ZachBreimayer_0-1679086882273.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now lets say we want to know what UnitPrice occurs most frequently, we want to count the number of records 'TheCount' and group by 'UnitPrice', we then can Order By the 'Count(*)' DESC to ensure the LineTotal with the most occurances is the first record in the result of the inner query. From here we can select 'TheCount' and 'LineTotal AS MODE' in the outer query and limit to just that first row with 'LIMIT 1'.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZachBreimayer_2-1679088295228.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2012i54648B61837A35A1/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ZachBreimayer_2-1679088295228.png" alt="ZachBreimayer_2-1679088295228.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In the result shown below we can see that our mode is 4.99 with 671384 occurances.&lt;/P&gt;&lt;P&gt;RESULT&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZachBreimayer_3-1679089135460.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2013i4C8BC3A97D39F54F/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ZachBreimayer_3-1679089135460.png" alt="ZachBreimayer_3-1679089135460.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From here there are several options including but not limited to the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1: Join it back into the model&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2: Apply the SQL logic and cross join into the source table(within the sql definition)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3: Define an internal session variable: This will make it globally usable across any formulas or elsewhere you want to simply reference the variable(mode) itself. I think this is possibly the best option especially if you want any level of detail without having to apply aggregate functions to persist the correct value(Avg) in downstream formulas.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Now we can go back to 'SCHEMAS' and create an internal session variable as shown here:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZachBreimayer_6-1679089463297.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2016iC1868E025D11F706/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ZachBreimayer_6-1679089463297.png" alt="ZachBreimayer_6-1679089463297.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We can then hit the test button and see our mode:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZachBreimayer_5-1679089441210.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2015i6D13C3A812110CCA/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ZachBreimayer_5-1679089441210.png" alt="ZachBreimayer_5-1679089441210.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now in the formula builder you can just use the variable to get the mode and reference it in formula builder.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZachBreimayer_7-1679089815447.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2017iA9A71942940E4829/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ZachBreimayer_7-1679089815447.png" alt="ZachBreimayer_7-1679089815447.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If we simply validate and save we can now see the Mode in the viz&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZachBreimayer_8-1679090322359.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2018i5F4DCD6044632704/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ZachBreimayer_8-1679090322359.png" alt="ZachBreimayer_8-1679090322359.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We can then drag the fields from salesorderdetail in and we get the same result for each record:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZachBreimayer_0-1679093188829.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2029iC5177548FE4F9044/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ZachBreimayer_0-1679093188829.png" alt="ZachBreimayer_0-1679093188829.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This brings us to a small nuance, internal session variables will result in a string so in order to do a mathematical calculation you can simply wrap the '$MODE' with double&amp;nbsp; as&amp;nbsp; 'double($MODE)'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZachBreimayer_2-1679092999550.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2028i5A7CA2B0F5C8A4B1/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ZachBreimayer_2-1679092999550.png" alt="ZachBreimayer_2-1679092999550.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We can visualize the new field 'UnitPrice-Mode' and compare to the adjacent fields used in the calc:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZachBreimayer_0-1679092883731.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2026i40304E4FB822500B/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ZachBreimayer_0-1679092883731.png" alt="ZachBreimayer_0-1679092883731.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If you need any help implementing a solution please reach out and I would be happy to assist.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Zach, Solution Engineer - Incorta&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 22:47:07 GMT</pubDate>
      <guid>https://community.incorta.com/t5/dashboards-analytics-discussions/mode-formula-in-incorta/m-p/3928#M343</guid>
      <dc:creator>ZachBreimayer</dc:creator>
      <dc:date>2023-03-17T22:47:07Z</dc:date>
    </item>
  </channel>
</rss>

