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
RobertSlattery
Resolver III
Resolver III

Rolling Average Time intelligence error

When I use Quick Measures to create a Rolling Average it generates the following DAX...

IF(
	ISFILTERED('Invoice_Summary All'[Date]),
	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 = LASTDATE('Dim Date'[Date].[Date])
	RETURN
		AVERAGEX(
			DATESBETWEEN(
				'Invoice_Summary All'[Date],
				DATEADD(__LAST_DATE, -6, DAY),
				__LAST_DATE
			),
			CALCULATE(SUM('Invoice_Summary All'[Sales Per Line]))
		)
)

I Date slicer on the page where I select the Last 12 Months.  Why does this throw if there is any filter on the date? I am filtering by the primary date column, so why is that a problem for the Time intelligence function?

1 ACCEPTED SOLUTION

It's because Power BI tries to help people by automatically generating hidden calendar tables that are related to Date columns in the model.  These hidden but separate Date tables are accessed using the dot notation like "'Dim Date'[Date].[Date]" and are required for some Power BI generated Quick Measures.  The quick measure is checking to make sure the user doesn't put a filter on their user created, non-hidden Date column ( 'Dim Date'[Date] in your case ) so the calculation does not return an incorrect result. I always create my own Calendar tables and turn off these hidden calendar tables so not sure if there is a workaround.  Of course, you could also just modify the Quick Measure Dax to remove the dot notation like this: 

 

Measure =
VAR __LAST_DATE =
    LASTDATE ( 'Dim Date'[Date] )
RETURN
    AVERAGEX (
        DATESBETWEEN (
            'Invoice_Summary All'[Date],
            DATEADD ( __LAST_DATE, -6, DAY ),
            __LAST_DATE
        ),
        CALCULATE ( SUM ( 'Invoice_Summary All'[Sales Per Line] ) )
    )

Quick Measures are a good way to learn DAX coding techniques.

 

Now that Power BI has the ability to "Mark as Date Table" like in excel, perhaps the Quick Meaures will be updated to use user created Calendar tables(?)

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

 

I can help you if you share the download link of your file.  Please also show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks, but I did it a diferent way to avoid the problem.

 

Can you help me to unserstand why having a filter on the date breakse the DATESBETWEEN function in this context?  To me, this makes it pretty much useless...

Hello,

 

I just had the same error but i don't know how can avoid this problem, if i remove the validation, it doesn't show the error but it does the wrong calculation, can you explain or show how you solved it?

 

Thanks,

Hello,

 

I just had the same error but i don't know how can avoid this problem, if i remove the validation, it doesn't show the error but it does the wrong calculation, can you explain or show how you solved it?

 

Thanks,

It's because Power BI tries to help people by automatically generating hidden calendar tables that are related to Date columns in the model.  These hidden but separate Date tables are accessed using the dot notation like "'Dim Date'[Date].[Date]" and are required for some Power BI generated Quick Measures.  The quick measure is checking to make sure the user doesn't put a filter on their user created, non-hidden Date column ( 'Dim Date'[Date] in your case ) so the calculation does not return an incorrect result. I always create my own Calendar tables and turn off these hidden calendar tables so not sure if there is a workaround.  Of course, you could also just modify the Quick Measure Dax to remove the dot notation like this: 

 

Measure =
VAR __LAST_DATE =
    LASTDATE ( 'Dim Date'[Date] )
RETURN
    AVERAGEX (
        DATESBETWEEN (
            'Invoice_Summary All'[Date],
            DATEADD ( __LAST_DATE, -6, DAY ),
            __LAST_DATE
        ),
        CALCULATE ( SUM ( 'Invoice_Summary All'[Sales Per Line] ) )
    )

Quick Measures are a good way to learn DAX coding techniques.

 

Now that Power BI has the ability to "Mark as Date Table" like in excel, perhaps the Quick Meaures will be updated to use user created Calendar tables(?)

Thanks, that is exactly the kind of answer I was looking for, Much apreciated.

 

I have the Jan version of PBI and can't see the Mark as Date Table option so I can't try it out.  One problem I have with your advice is that I can't use Time Intelligence functions requiring dot notation if I disable Auto Date/Time, so I can't access the hierarchy.  Hopefully this will be fixed with the latest version.

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.