Calculated Column versus Measure syntax

dicken

Active Member
Joined
Feb 12, 2022
Messages
292
Office Version
  1. 365
Platform
  1. Windows
Hi,
Can someone explain why in a cumulative total by date in a calculated column the filter needs the whole table, as opposed to a measure,
where the advice seems to be use the least number of columns so in this case one ; date. But if I just put filer Table[ Date] in a CC I
just get back the row value? what's happening?
Calculated column Filter entire table

Excel Formula:
 CALCULATE(SUM(Table1[Sales]), FILTER(ALL(Table1),
                                                                           Table1[Date]<= EARLIER(Table1[Date]) ))

Measure just date ;


Excel Formula:
RTC :=
VAR sdate =
    MAX ( Table1[Date] )
RETURN
    CALCULATE (
        SUM ( Table1[Sales] ),
        FILTER ( ALL ( Table1[Date] ), Table1[Date] <= sdate )
    )
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
When you use calculate in a calculated column, the row context (always exists in a calc column) is converted to a filter context. Every column in the table is converted to a filter context, so you need to remove the filter from all columns, aka, the table.
To demonstrate, try adding all (or simply more) columns to a visual (rows) and then see what your measure does.
Also try a calculated column without a calculate.
test column=SUM(Table1[Sales])
 
Upvote 0
Solution
When you use calculate in a calculated column, the row context (always exists in a calc column) is converted to a filter context. Every column in the table is converted to a filter context, so you need to remove the filter from all columns, aka, the table.
To demonstrate, try adding all (or simply more) columns to a visual (rows) and then see what your measure does.
Also try a calculated column without a calculate.
test column=SUM(Table1[Sales])
Thanks, that does make sense, I think, adding more columns to the source table didn't make a difference to the measure,
I didn't expect it would. Should it have ?

Richard.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top