Forum Discussion
Alexis_Piper
Mar 25, 2026Copper Contributor
Complex formulae with data model
Over the years, I have developed a significant excel data sheet which has gotten slower and slower with time. I have discovered the idea of excel's data model this week and have learnt how to impor...
Olufemi7
Mar 25, 2026Iron Contributor
Hello Alexis_Piper,
Your current formula works in the worksheet because it checks cells to the left but will not work in the Data Model or Power Pivot. To count only the first occurrence per row by month, unpivot your months in Power Query and add a calculated column: FirstMonth = CALCULATE(MIN(Table[Month]), ALLEXCEPT(Table, Table[RowID])) CountFlag = IF(Table[Month] = Table[FirstMonth], Table[Value], 0) This counts only the first occurrence. Worksheet formulas still work but will slow performance on large datasets.