Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

3MM From Static Date in The Past

Hello PB Team,

I have a task to build a calculation that counts the number of responses every 3 months from the 20th day of each month + 3 months. For example, if today is the 8th of February, it must count the previous period: January 20th, 2021 - October 20th, 2020 but if today is February 20, it must show me February 20th, 2021 - November 20th, 2020, and so on like this:

Capture1.PNG

 

I build a variable but somehow the 'VAR EndDateBefore20' doesn't work and I can't find an alternative. Please Help. Thank you.

Period 3MM =
VAR StartDateBefore20 = EDATE (STARTOFMONTH('Calendar'[Date])+19, -4)
VAR EndDateBefore20 = EDATE (STARTOFMONTH('Calendar'[Date])+19, -1)
VAR StartDateAfter20 = EDATE (STARTOFMONTH('Calendar'[Date])+19, -3)
VAR EndDateAfter20 = EDATE (STARTOFMONTH('Calendar'[Date])+19, 0)

RETURN
IF(DAY(TODAY())<20,CALCULATE([# Responses],CALCULATETABLE(
'Calendar',
FILTER (
'Calendar',
'Calendar'[Date] >= StartDateBefore20
&& 'Calendar'[Date] <= EndDateBefore20
)))
,
IF(DAY(TODAY())>20,CALCULATE ([# Responses],CALCULATETABLE(
'Calendar',
FILTER (
'Calendar',
'Calendar'[Date] >= StartDateAfter20
&& 'Calendar'[Date] <= EndDateAfter20
))),
BLANK()
))

Please, help.
Thank you very much.

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You can get start and end date of your period like

Var EndDate = eomonth('Calendar'[Date]-19,-1)+20
Var startdate = date(year(EndDate), month(EndDate)-3, day(EndDate))

 

and can do rest of calculation on these

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , You can get start and end date of your period like

Var EndDate = eomonth('Calendar'[Date]-19,-1)+20
Var startdate = date(year(EndDate), month(EndDate)-3, day(EndDate))

 

and can do rest of calculation on these

Anonymous
Not applicable

@amitchandak Thank you very much! Somehow the combination of eomonth('Calendar'[Date] doesn't work in a measure, so I combined it with EndOfMonth. So the result is:

LSP 3MM -1 = 
VAR EndDateLess20 = EOMONTH(ENDOFMONTH('Calendar'[Date])-19,-1)+20
VAR StartDateLess20 = DATE(YEAR(EndDateLess20), MONTH(EndDateLess20)-3, DAY(EndDateLess20))
VAR EndDateMore20 = EOMONTH(ENDOFMONTH('Calendar'[Date])-19,0)+20
VAR StartDateMore20 = DATE(YEAR(EndDateMore20), MONTH(EndDateMore20)-3, DAY(EndDateMore20))

RETURN
    IF(DAY(TODAY())<=20,CALCULATE([Channel NPS],CALCULATETABLE(
            'Calendar',
            FILTER (
                'Calendar',
                'Calendar'[Date] > StartDateLess20
                    && 'Calendar'[Date] <= EndDateLess20
            )))
,
     CALCULATE ([Channel NPS],CALCULATETABLE(
            'Calendar',
            FILTER (
                'Calendar',
                'Calendar'[Date] > StartDateMore20
                    && 'Calendar'[Date] <= EndDateMore20
            ))))

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.