Forum Discussion
How to dynamically total/count across multiple columns of a dynamic array
- PeterBartholomew1Oct 07, 2023Silver Contributor
I completely accept that the Pivot Table will give the same result. One has a choice.
It is also faster to achieve the result provided:-
1. The developer has spent time to understand pivot tables
2. They have not already developed the worksheet formula and saved it as a Lambda function.
But then the same could be said for VBA or Python (give or take a few Command buttons, Refresh or menu picks). I suspect that to have fluency in each of these areas such as you do is rare. At present, I stick to the worksheet formula environment until the case to shift technologies is overwhelming.
- SergeiBaklanOct 07, 2023Diamond Contributor
I mentioned PivotTable only as comment to remind other options exist. For such case it doesn't require DAX and advanced data modelling skills. Refresh is a minus, more dynamic formatting is a plus.
Power Query here as easy as PivotTable, just two steps - query the source and GroupBy office/product. But it less common than PivotTable and also requires Refresh.
- PeterBartholomew1Oct 07, 2023Silver ContributorSpoilt for choice!!!
- PeterBartholomew1Oct 07, 2023Silver Contributor
You have been busy while I was having breakfast!
My formula was
= LET( distinctCategories, SORT(UNIQUE(SalesTbl[[Office]:[Produce]]), {1,2}), office, CHOOSECOLS(distinctCategories, 1), product, CHOOSECOLS(distinctCategories, 2), entries, COUNTIFS(SalesTbl[Office], office, SalesTbl[Produce], product), sales, SUMIFS(SalesTbl[Sales], SalesTbl[Office], office, SalesTbl[Produce], product), HSTACK(office, product, entries, sales) )- SergeiBaklanOct 07, 2023Diamond Contributor
Oh, yes, I was between breakfast and lunch. Plus you spent more time to generate friendly source table.