Since you were unable to find a "formula", I'll derive one here, but for the TLDR, just go to the end.

For a periodic waveform \$f\$, like a sinusoid \$f(t) = sin(t)\$, the way to find the average is to integrate the signal over a single cycle, and then divide by the period of that cycle:

$$ M = \frac{1}{T}\int_{t=0}^{T}{f(t)\cdot dt} $$

If you have a non-continuous waveform, like a square or rectangle, this isn't going to work, because there's no single continuous, integrable function that describes it, due to the instantaneous rises and falls. However, you can split the wave into partitions, each being a section of the waveform that *can* be described as a continuous integrable function, and integrate "piece-wise":

$$ \frac{1}{T}\int_{t=0}^{T}{f(t)\cdot dt} = \frac{1}{T}\left[\int_{t=0}^{t_1}{f(t)\cdot dt} + \int_{t=t_1}^{T}{f(t)\cdot dt}\right] $$

If you look closely, the section inside the square brackets is just the sum of two integrals, taken over intervals \$0<t<t1\$, and \$t_1<t<T\$, where \$t_1\$ is some instant in time within a single cycle. The first integral operates on the function prior to time \$t=t_1\$, and the second integral operates on the waveform following that instant. You can define as many partitions, or "pieces", as you want.

For a rectangular wave, though, we need only two intervals, the first being where the signal is at one potential (a constant value \$V_P\$ in your case), and the second where the signal has some other value (such as \$V_N\$). I will call these values \$Y_1\$ and \$Y_2\$, which are two constants representing the values of our rectangular function in each interval.

Considering that time \$t=0\$ represents the beginning the first partition, time \$t=t_1\$ is the instant where the first partition ends and the second one begins, and time \$t=T\$ is the end of the second partition, we can define the durations of each partition \$T_1\$ and \$T_2\$ to be:

$$
\begin{aligned}
T_1 = t_1 - 0 \\ \\
T_2 = T - t_1 \\ \\
\end{aligned}
$$

Let's integrate during the first interval:

$$
\begin{aligned}
f_1(t) &= Y_1 \\ \\
\int_{t=0}^{t_1}{f_1(t)\cdot dt} &= \int_{t=0}^{t_1}{Y_1\cdot dt}\\ \\
&= \left[\vphantom{\frac{}{}}Y_1\cdot t\right]_0^{t_1} \\ \\
&= Y_1 (t_1 - 0) \\ \\
&= Y_1T_1
\end{aligned}
$$

During the second interval:

$$
\begin{aligned}
f_2(t) &= Y_2 \\ \\
\int_{t=t_1}^T{f_2(t)\cdot dt} &= \int_{t=t_1}^T{Y_2\cdot dt}\\ \\
&= \left[\vphantom{\frac{}{}}Y_2\cdot t\right]_{t_1}^T \\ \\
&= Y_2 (T - t_1) \\ \\
&= Y_2T_2
\end{aligned}
$$

Plugging these into the piece-wise integral from before, mean \$M\$ will be:

$$
\begin{aligned}
M &= \frac{1}{T}\left[\int_{t=0}^{t_1}{f_1(t)\cdot dt} + \int_{t=t_1}^{T}{f_2(t)\cdot dt}\right] \\ \\
&= \frac{1}{T}\left[Y_1T_1 + Y_2T_2\right] \\ \\
&= Y_1\frac{T_1}{T} + Y_2\frac{T_2}{T} \\ \\
\end{aligned}
$$

Notice that \$\frac{T_1}{T}\$ is the fraction of a complete cycle that the function spends with value \$Y_1\$. Likewise, \$\frac{T_2}{T}\$ represents the fraction of the cycle spent at \$Y_2\$. If I define \$D\$ to be the former, called the "duty cycle", then we have:

$$ \frac{T_1}{T} = D $$

\$T_2\$ must be the *remaining* fraction of *one* cycle:

$$ \frac{T_2}{T} = 1-D $$

Substituting those into our equation for the mean:

$$
\begin{aligned}
M &= Y_1\frac{T_1}{T} + Y_2\frac{T_2}{T} \\ \\
&= Y_1D + Y_2(1-D)
\end{aligned}
$$

D is dimensionless, it's just a fraction of 1. That means for a periodic rectangular waveform, the mean value is completely independent of frequency or period. The same is true for *any* periodic waveform.

<hr>

### TLDR

The fraction of a complete cycle that your waveform spends at value \$V_P\$ is \$D=\frac{4}{10}\$ (I figured this out just by counting the squares; period \$T\$ is irrelevant here). The remaining time at \$V_N\$ is \$1-D=\frac{6}{10}\$.

Plug those into the equation we derived above:

$$
\begin{aligned}
M &= Y_1D + Y_2(1-D) \\ \\
&= 41\times \frac{4}{10} + (-6)\times \frac{6}{10} \\ \\
&= 12.8V
\end{aligned}
$$

RMS is the square **R**oot of the **M**ean of the **S**quare of the signal over one cycle. Importantly, the result of squaring a rectangular waveform is another rectangular waveform with the exact same duty cycle, so we can use the same formula derived above, with the same value for \$D\$, but with values \${V_P}^2\$ and \${V_N}^2\$ instead:

$$
\begin{aligned}
V_{RMS} &= \sqrt{{V_P}^2D + {V_N}^2(1-D)} \\ \\
&= \sqrt{1681\times \frac{4}{10} + 36\times \frac{6}{10}} \\ \\
&= \sqrt{694} \\ \\
&= 26.3V
\end{aligned}
$$