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

Quick measure rolling average shows future dates

How can I do to disappear with the months highlighted as shown below?

I don't need the future dates (oct to dec 2020).

 

avg_time.PNG

 

 

My DAX for the one measure used in this axis:

 

Count of events 6 MO =
IF(
    ISFILTERED('tb_aog'[INICIO]),
    ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
    VAR __LAST_DATE = ENDOFMONTH('tb_aog'[INICIO].[Date])
    VAR __DATE_PERIOD =
        DATESBETWEEN(
            'tb_aog'[INICIO].[Date],
            STARTOFMONTH(DATEADD(__LAST_DATE, -5, MONTH)),
            ENDOFMONTH(DATEADD(__LAST_DATE, 0, MONTH))
        )
    RETURN
IF (
YEAR ( __LAST_DATE ) IN ALLSELECTED ( tb_aog[INICIO].[Year] ),
        AVERAGEX(
            CALCULATETABLE(
                SUMMARIZE(
                    VALUES('tb_aog'),
                    'tb_aog'[INICIO].[Year],
                    'tb_aog'[INICIO].[QuarterNo],
                    'tb_aog'[INICIO].[Quarter],
                    'tb_aog'[INICIO].[MonthNo],
                    'tb_aog'[INICIO].[Month]
                ),
                __DATE_PERIOD
            ),
            CALCULATE([Count of events], ALL('tb_aog'[INICIO].[Day]))
        )
))

 

 

 

 

Thanks in advance.

Marcos

2 ACCEPTED SOLUTIONS

@Anonymous - Use MIN instead of MAX


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

@Anonymous , another way out is

if( max('tb_aog'[INICIO].[Date]) >= Eomonth(today()-1) , blank(),

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Great!! Thank you @amitchandak and @Greg_Deckler for your attention on this matter. Super helpful!!

Have you guys a great day!

Anonymous
Not applicable

Great!! Saved my day!! Fixed

@Anonymous , another way out is

if( max('tb_aog'[INICIO].[Date]) >= Eomonth(today()-1) , blank(),

Anonymous
Not applicable

Perfect, but Sep 2020 disappeared.

 

avg.PNG

 

 

@Anonymous - Use MIN instead of MAX


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@Anonymous , Assuming 'tb_aog'[INICIO].[Date] is used on axis. else use the date on axis

Try

 

Count of events 6 MO =
if( max('tb_aog'[INICIO].[Date]) >= today(), blank(),
IF(
ISFILTERED('tb_aog'[INICIO]),
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
VAR __LAST_DATE = ENDOFMONTH('tb_aog'[INICIO].[Date])
VAR __DATE_PERIOD =
DATESBETWEEN(
'tb_aog'[INICIO].[Date],
STARTOFMONTH(DATEADD(__LAST_DATE, -5, MONTH)),
ENDOFMONTH(DATEADD(__LAST_DATE, 0, MONTH))
)
RETURN
IF (
YEAR ( __LAST_DATE ) IN ALLSELECTED ( tb_aog[INICIO].[Year] ),
AVERAGEX(
CALCULATETABLE(
SUMMARIZE(
VALUES('tb_aog'),
'tb_aog'[INICIO].[Year],
'tb_aog'[INICIO].[QuarterNo],
'tb_aog'[INICIO].[Quarter],
'tb_aog'[INICIO].[MonthNo],
'tb_aog'[INICIO].[Month]
),
__DATE_PERIOD
),
CALCULATE([Count of events], ALL('tb_aog'[INICIO].[Day]))
)
)) )

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.