Show 2 random entries based on checkbox in Super Table I have a Super Table field (entryType) with a checkbox field "featuredIn" and some values.  



This is how it looks when creating a entry:


I can't figure out how to mix "slice" and "orderBy RAND" with filtering by that field.  

This does show me 2 random entries from all:

{% set entries = craft.entries.section('blog').orderBy('RAND()').all() %}

{% for entry in entries|slice(0, 2) %}
  {{ entry.title }}
{% endfor %}


This shows me only the entries where "showInRandom" is checked (but not random and not only 2):  

{% for entry in craft.entries.section('blog') if entry.entryType.featuredIn.contains('showInRandom') %}
  {{ entry.title }}
{% endfor %}
The question is pretty confusing so this answer assumes the following:

You have a Super Table field named entryType with the following cells:


featuredIn (checkbox)
showInRandom (checkbox)


And that you are trying to:


Only show rows where showInRandom is checked
Randomize the order of the rows that are returned
Limit the returned results to 2


Unfortunately Super Table doesn't support searching based on a block's value, which I see you already know, so you'll have to do it in steps.

First, you need to pull in every Super Table row. Then you need to check if each row has showInRandom checked (side note: a lightswich field would be easier), and add its ID to an array if so. Then you randomize the array and run a Super Table query with those IDs and limit the results to 2.

{# create an array to store the returned IDs #}
{% set randomRows = [] %}

{# add only the rows with showInRandom selected to the array #}
{% for row in entry.entryType.all %}
    {% if row.showInRandom.options[0].selected %}
        {% set randomRows = randomRows|merge([row.id]) %}
    {% endif %}
{% endfor %}

{# randomize the array and run a super table query, limiting to 2 #}
{% for row in craft.superTable.blocks({
    owner: entry,
    fieldId: 123,
    id: shuffle(randomRows),
    fixedOrder: true,
    limit: 2
}).all %}
    {{ row.someField }}&lt;br&gt;
{% endfor %}