Conditional Calculated Measure by Date

Am I able to get DateCompare to return True for specific dates in the Time dimension?

Test 2 =
DateBetween([Time.Weekly].CurrentHierarchyMember,
[Time.Weekly].[2020].[W23, Jun 05 2020],
[Time.Weekly].[2020].[W25, Jun 19 2020])

Always seems to return false, what am I missing? I am trying to set a calculated measures value based on the date in the time dimension and am running out of ideas :slight_smile:

Although I still don’t understand why the original DateBetween above did not work, the below worked for me.

DateBetween(
[Time].CurrentHierarchyMember.StartDate,
‘06-05-2020’,
‘06-11-2020’
)

This returned True for the 06-05-2020 through 06-11-2020.

1 Like

Hi,

Great, you already found the solution!

In the DateBetween() function you must use three date values.
[Time].CurrentHierarchyMember is a dimension member, not a date; you transform it to date with function StartDate which retrieves the first date of this Time dimension member.
The same goes for [Time.Weekly].[2020].[W23, Jun 05 2020] and [Time.Weekly].[2020].[W25, Jun 19 2020] - in this case, as you need two particular dates, it is easier to write exact dates.

You may want to watch about how to read syntax and detect data types when creating calculations: https://docs.eazybi.com/eazybijira/learn-more/training-videos/training-videos-on-specific-topics#Trainingvideosonspecifictopics-MDXABC:Let’sstartattheverybeginning(30min) (after 16:10)

Best,
Ilze / support@eazybi.com