Calculated Column versus Measure syntax

dicken

Active Member
Joined
Feb 12, 2022
Messages
283
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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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,215,200
Messages
6,123,601
Members
449,109
Latest member
Sebas8956

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