<?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 Re: Combinatorics, permutation, foreach within a foreach... unique stats case to calculate a fields vertical relationshi in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618968#M215121</link>
    <description>&lt;P&gt;If you want any 2 groups with a common position:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup position_group_lookup.csv
| rename group AS group_1
| lookup position_group_lookup.csv position OUTPUT group AS group_2
| mvexpand group_2
| table group_1 group_2 position&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;If you want any 2 groups and the list of common positions and % intersect:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup position_group_lookup.csv
| rename group AS group_1
| eventstats dc(position) AS p1_position_ct BY group_1
| lookup position_group_lookup.csv position OUTPUT group AS group_2
| table group_1 position group_2 p1_position_ct 
| mvexpand group_2
| stats values(position) AS common_positions dc(position) AS common_ct max(p1_position_ct) AS p1_position_ct BY group_1 group_2 
| eval percent_common=ROUND((common_ct/p1_position_ct*100), 2)." %"
| sort 0 -percent_common&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 31 Oct 2022 16:11:51 GMT</pubDate>
    <dc:creator>johnhuang</dc:creator>
    <dc:date>2022-10-31T16:11:51Z</dc:date>
    <item>
      <title>Combinatorics, permutation, foreach within a foreach... unique stats case to calculate a fields vertical relationship?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618757#M215051</link>
      <description>&lt;P class="lia-align-left"&gt;I have a unique query that I think I have a general logical approach to solving, but the syntax and most efficient route is TBD&amp;gt;&amp;gt;&amp;nbsp; Case to solve is this:&lt;BR /&gt;&lt;BR /&gt;Users are assigned positions in an application, each position is unique.&amp;nbsp; Positions are assigned security groups that are mapped to roles.&lt;BR /&gt;&lt;BR /&gt;We are versioning this mapping into splunk for two reasons.&amp;nbsp; 1 to be able to rewind and show who was in what groups so that we can do whatif scenarios 9 months back without trying to figure out what has changed etc. and 2.&amp;nbsp; We want to analyze overlap in positions to roles to help simplify where necessary.&amp;nbsp; The latter is the basis of my question.&lt;BR /&gt;&lt;BR /&gt;I have a table created off a makemv/mvexpand that creates a cube of data that has&amp;nbsp;&lt;BR /&gt;Position, GroupName&lt;BR /&gt;&lt;BR /&gt;There are say 99 unique positions and 70 unique security groups.&lt;BR /&gt;&lt;BR /&gt;Expanded I have just north of 1200 permutations of them&lt;BR /&gt;&lt;BR /&gt;Position1, SecGroup1&lt;BR /&gt;Position1, SecGroup2&lt;BR /&gt;Position2, SecGroup2&lt;BR /&gt;Position2, Secgroup5&lt;BR /&gt;Position3, SecGroup1&lt;BR /&gt;Position4, SecGroup2&lt;BR /&gt;&lt;BR /&gt;Etc&lt;BR /&gt;&lt;BR /&gt;What I need to do is create stats on the relationship of overlap where positions are in similar groups&amp;gt;&lt;BR /&gt;&lt;BR /&gt;I know for instance that in my current data set that ALL positions are in SecGroup1&lt;BR /&gt;and 68/99 are in SecGroup2&lt;BR /&gt;&lt;BR /&gt;This is easily calculated for one group, but how do I extend this out at scale for all group?&lt;BR /&gt;&lt;BR /&gt;I am thinking of creating a deduplicated list of security groups, and creating a full list of all combinations of&amp;nbsp;&lt;BR /&gt;(SecGroup1 AND SecGroup2) OR (SecGroup1 AND SecGroup3)&amp;nbsp; until that goes in reverse and deduplicating that list and using that list as a subsearch to my raw data and then running stats on it that I would think in theory would show where two PD's overlap because of the same two groups?&lt;BR /&gt;&lt;BR /&gt;Is there a more succinct way of doing this?&amp;nbsp; Can one create this list with | foreach to a foreach to create this list?&amp;nbsp; How in splunk can one calculate a list of permutations and force an AND between them as a part of a subquery?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 16:31:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618757#M215051</guid>
      <dc:creator>tobiasboone1</dc:creator>
      <dc:date>2022-10-28T16:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorics, permutation, foreach within a foreach... unique stats case to calculate a fields vertical relationshi</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618797#M215061</link>
      <description>&lt;P&gt;Does this help?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats values(group) as groups by position
| eval groups=mvjoin(groups,",")
| stats values(position) as positions by groups&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 28 Oct 2022 20:13:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618797#M215061</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-10-28T20:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorics, permutation, foreach within a foreach... unique stats case to calculate a fields vertical relationshi</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618814#M215067</link>
      <description>&lt;P&gt;If you're trying to figure out the common groups and % intersect between any 2 positions, here's a possible way of doing it:&lt;/P&gt;&lt;P&gt;1. Let's generate test data and save it into a lookup:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval position=mvrange(1,99)
| mvexpand position | eval position="Position".position
| eval rng=(random() % 30) | eval group=mvrange(1,rng)
| mvexpand group | eval rng=(random() % 50)
| eval group="SecGroup".rng | dedup position group
| table position group
| outputlookup position_group_lookup.csv&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup position_group_lookup.csv
| rename position AS position_1
| eventstats dc(group) AS p1_group_ct BY position_1
| lookup position_group_lookup.csv group OUTPUT position AS position_2
| table position_1 group position_2 p1_group_ct
| mvexpand position_2
| stats values(group) AS common_groups dc(group) AS common_ct max(p1_group_ct) AS p1_group_ct BY position_1 position_2
| eval percent_common=ROUND((common_ct/p1_group_ct*100), 2)." %"&lt;/LI-CODE&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>Sat, 29 Oct 2022 03:33:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618814#M215067</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-10-29T03:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorics, permutation, foreach within a foreach... unique stats case to calculate a fields vertical relationshi</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618936#M215110</link>
      <description>&lt;P&gt;Would it be possible to do this as a subsearch and a join as well instead of a lookup?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 14:31:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618936#M215110</guid>
      <dc:creator>tobiasboone1</dc:creator>
      <dc:date>2022-10-31T14:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorics, permutation, foreach within a foreach... unique stats case to calculate a fields vertical relationshi</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618953#M215111</link>
      <description>&lt;P&gt;Thank you both for your feedback.&amp;nbsp; Perhaps my request needs to be a bit more specific.&amp;nbsp; The examples above are essentially another way of doing a selfjoin on groups; which returns back a disassociated set of which groups overlap with which positions; somewhere.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;What I really want is to show which groups show up in tandem with multiple positions.&amp;nbsp; Ie; which groups can I likely get rid of because they are redundant.&lt;BR /&gt;&lt;BR /&gt;I believe what I need to do is create a subsearch that creates the permutations by starting with a deduplicated list of groups:&lt;BR /&gt;&lt;BR /&gt;| makeresults | eval position=mvrange(1,99)&lt;BR /&gt;| mvexpand position | eval position="Position".position&lt;BR /&gt;| eval rng=(random() % 30) | eval group=mvrange(1,rng)&lt;BR /&gt;| mvexpand group | eval rng=(random() % 50)&lt;BR /&gt;| eval group="SecGroup".rng | dedup position group&lt;BR /&gt;| table position group&lt;BR /&gt;| dedup group | fields group | sort group&lt;BR /&gt;&lt;BR /&gt;and then creating a foil operation somehow to return each combination of those deduplicated&lt;BR /&gt;ie:&lt;BR /&gt;first AND last&lt;BR /&gt;first AND secondtolast&lt;BR /&gt;first AND Lsub2 etc&lt;BR /&gt;&lt;BR /&gt;I could take this and run it inside my initial query to return back sets where both are true and then run stats against it.&lt;BR /&gt;&lt;BR /&gt;I just can't figure out a way to have a splunk command do this first, inside, outside operation to return back combinations of values from a search/lookup.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 15:20:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618953#M215111</guid>
      <dc:creator>tobiasboone1</dc:creator>
      <dc:date>2022-10-31T15:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorics, permutation, foreach within a foreach... unique stats case to calculate a fields vertical relationshi</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618958#M215113</link>
      <description>&lt;P&gt;If I understand correctly, you want to find the groups which have the same positions in?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats values(position) as positions by group
| eval positions=mvjoin(positions,",")
| stats values(group) as groups by positions&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 31 Oct 2022 15:45:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618958#M215113</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-10-31T15:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorics, permutation, foreach within a foreach... unique stats case to calculate a fields vertical relationshi</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618962#M215115</link>
      <description>&lt;P&gt;More specifically, pairs unique pairs groups.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 15:57:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618962#M215115</guid>
      <dc:creator>tobiasboone1</dc:creator>
      <dc:date>2022-10-31T15:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorics, permutation, foreach within a foreach... unique stats case to calculate a fields vertical relationshi</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618963#M215116</link>
      <description>&lt;P&gt;Which group have the same list of positions?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 16:00:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618963#M215116</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-10-31T16:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorics, permutation, foreach within a foreach... unique stats case to calculate a fields vertical relationshi</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618967#M215120</link>
      <description>&lt;P&gt;what two groups in combination show up in various positions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 16:05:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618967#M215120</guid>
      <dc:creator>tobiasboone1</dc:creator>
      <dc:date>2022-10-31T16:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorics, permutation, foreach within a foreach... unique stats case to calculate a fields vertical relationshi</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618968#M215121</link>
      <description>&lt;P&gt;If you want any 2 groups with a common position:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup position_group_lookup.csv
| rename group AS group_1
| lookup position_group_lookup.csv position OUTPUT group AS group_2
| mvexpand group_2
| table group_1 group_2 position&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;If you want any 2 groups and the list of common positions and % intersect:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup position_group_lookup.csv
| rename group AS group_1
| eventstats dc(position) AS p1_position_ct BY group_1
| lookup position_group_lookup.csv position OUTPUT group AS group_2
| table group_1 position group_2 p1_position_ct 
| mvexpand group_2
| stats values(position) AS common_positions dc(position) AS common_ct max(p1_position_ct) AS p1_position_ct BY group_1 group_2 
| eval percent_common=ROUND((common_ct/p1_position_ct*100), 2)." %"
| sort 0 -percent_common&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 16:11:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618968#M215121</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-10-31T16:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorics, permutation, foreach within a foreach... unique stats case to calculate a fields vertical relationshi</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618999#M215136</link>
      <description>&lt;P&gt;This totally works... I have to go back and figure out exactly WHY!&amp;nbsp; But it works.&amp;nbsp; I envy the way some of your brains work with these things!&amp;nbsp; Thank you!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 18:56:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combinatorics-permutation-foreach-within-a-foreach-unique-stats/m-p/618999#M215136</guid>
      <dc:creator>tobiasboone1</dc:creator>
      <dc:date>2022-10-31T18:56:45Z</dc:date>
    </item>
  </channel>
</rss>

