Forum Discussion

NewbieJono's avatar
NewbieJono
Icon for Post Partisan rankPost Partisan
2 years ago

Flag in Date table

Hello, is it possible to set a flag for dates between the 1st of april and the max date in another table?

 

e.g if the max date was may 28th it would flag

 

2024 - 01/04/2024 to 28/05/2024

2023 - 01/04/2023 to 28/05/2023

2022 - 01/04/2022 to 28/05/2022

 

etc

3 Replies

  • NewbieJono try something like this:

     

    Flag = 
    VAR __MaxDate = CALCULATE ( MAX ( YourTable[Date] ) )  
    VAR __RangeStart = DATE ( YEAR ( 'Calendar'[Date] ), 4, 1 )
    VAR __RangeEnd = DATE ( YEAR ( 'Calendar'[Date] ), MONTH ( __MaxDate ), DAY ( __MaxDate ) )
    RETURN
    IF ( 'Calendar'[Date] >= __RangeStart && 'Calendar'[Date] <= __RangeEnd, 1 )
  • NewbieJono Just to confirm, the date columns in the fact, and dim tables are of date type, correct?