# Calculate a sum excluding hidden columns, how?

Occasional Visitor

# Calculate a sum excluding hidden columns, how?

Hi,

I’m trying to calculate a total at the end of a row and I have hidden columns. How do I exclude those hidden columns? I’ve tried doing =subtotal and =aggregate but this didn’t work as I’m trying to exclude a column and not a row.

Thank you.
2 Replies

# Re: Calculate a sum excluding hidden columns, how?

So much--so VERY much--depends on the exact situation.

Like

• how many columns are hidden,
• why are they hidden (if there's a constant condition that could be used in a conditional format, for example)...
• is the design permanent,
• could the hidden columns be moved to the right or left of the column where you want to determine the total?

Personally, I'd want to think about the implications of each of those questions first. Any other solution would potentially be vulnerable to future changes that make the resulting totals unreliable. A good design tries to reduce the risk of unintended side effects. Hidden columns (which admittedly can be useful) are potential time bombs depending on who uses the resulting spreadsheet, how much they're allowed to do, etc.

# Re: Calculate a sum excluding hidden columns, how?

I am also not a fan of hiding cells as a way of conveying information.  However

``````visible
= SIGN(INDEX(CELL("width",(@data)),1))

= SUM(IF(visible,data))``````

might work for you.

Of course, I might use

``````= SUM(IF(MAP(data, Visibleλ), data))

where Visibleλ is given by
=LAMBDA(c,SIGN(INDEX(CELL("width",c),1)))``````

but that is just showing off how different modern Excel can be.