DAX - Calculated Column with L12M filter based on row context dates

aldousjg

New Member
Joined
Jan 20, 2021
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am trying to create a calculated column to return a distinct count of "ID" based on two filter conditions:

1) "Person ID" is equal to "Person ID" of current row.
2) "Start Date" is within L12M from "Start Date" of current row.

I've got 1) to work, but cannot get 2) to work. Here's my DAX which achieves 1):
CALCULATE(
DISTINCTCOUNT('Table'[ID]),
FILTER(ALL('Table'), 'Table'[Person ID] = EARLIER('Table'[Person ID]))
)

I have tried the below to get 2) to work but I get an error of a table being supplied where a single value is expected:
CALCULATE(
DISTINCTCOUNT('Table'[ID]),
FILTER(ALL('Table'), 'Table'[Person ID] = EARLIER('Table'[Person ID])),
FILTER(ALL('Table'), 'Table'[Start Date] >= DATESINPERIOD('Table'[Start Date], EARLIER('Table'[Start Date]), -12, MONTH))
)

Can anyone help?

Thank you,
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,215,621
Messages
6,125,884
Members
449,269
Latest member
GBCOACW

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