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

Actuals vs Average + Chart Date Filtering

Hi all,

 

Having an issue with filtering a chart that contains a measure which subtracts a 3-month average of Actuals pre Project start date (Dec19) from current Actuals.

Per screenshot below, when I add a Date filter with advanced filter 'is on or after' Dec19, I still see all of 2019 and 2021.

I only want to see Dec19 to today's date (Nov20).

VALUE MEASURE

 

BRR.VS.AVG =
IF(
MAX( PROJECT_LOOKUP[RFS.IND] ) = "No"
, 0
, IF(
MAX( 'CALENDAR'[Date] ) < MAX( PROJECT_LOOKUP[RFS.DATE] )
, 0
, [MRR(no RFS)] - [AVG.PRE-REV]
))

 

SUPPORTING MEASURES

 

MRR(no RFS) =
CALCULATE(
SUM( REVENUE[USD_BUDGET_AMT] )
, REVENUE[GL_REVENUE_CATEGORY_CD] = "BRR"
|| REVENUE[GL_REVENUE_CATEGORY_CD] = "Billable Run Rate"
)

 

AVG.PRE-REV =
CALCULATE(
[MRR(no RFS)]
, DATESINPERIOD( 'CALENDAR'[Date] , EDATE( MIN( PROJECT_LOOKUP[RFS.DATE] ), -1 ) , -3 , MONTH )
)
/3

 

PBIX FILE 

 

 

Visual1.PNG

 

 

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Sorry for the late reply,try to use "dateadd" instead of "dateinperiod":

AVG.PRE-REV =
CALCULATE(
[MRR(no RFS)]
, DATEADD( 'CALENDAR'[Date] , -3 , MONTH )&&
MAX( PROJECT_LOOKUP[RFS.DATE] )<=DATE(2020,11,31)))
/3

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @v-kelly-msft , understood re. the relationships, however even with the correct schema, the visual still shows all of 2019 and 2021 (albeit now with blanks).

I want to only show the months of 2020 up until November.

Thanks,

Jake

Hi  @Anonymous ,

 

How about modifying your measure as below:

AVG.PRE-REV =
CALCULATE(
[MRR(no RFS)]
, DATESINPERIOD( 'CALENDAR'[Date] , EDATE( MIN( PROJECT_LOOKUP[RFS.DATE] ), -1 ) , -3 , MONTH )&&
MAX( PROJECT_LOOKUP[RFS.DATE] )<=DATE(2020,11,31)))
/3

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Anonymous
Not applicable

Hi @v-kelly-msft ,

Unfortunately this modification generates an error:

"A function 'DATESINPERIOD' has been used in a True/False expression that is used as a table filter expression. This is not allowed."

I tried adding a 'FILTER ( ALL (' to correct it but still came up with the same error.

I do think that the answer is somewhere in modifying one or more of these measures though

Any thoughts?

Kind regards,

Jake

Hi @Anonymous ,

 

Sorry for the late reply,try to use "dateadd" instead of "dateinperiod":

AVG.PRE-REV =
CALCULATE(
[MRR(no RFS)]
, DATEADD( 'CALENDAR'[Date] , -3 , MONTH )&&
MAX( PROJECT_LOOKUP[RFS.DATE] )<=DATE(2020,11,31)))
/3

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

Anonymous
Not applicable

Hi @v-kelly-msft,

That measure still generates an error:

"A function 'DATESADD' has been used in a True/False expression that is used as a table filter expression. This is not allowed."

 

 

Jake

Anonymous
Not applicable

@v-kelly-msft thanks for the response.

 

I still have the issue that the months are still visible outside of the range I want to see (i.e. all of 2019 and 2021).

 

Also, in my actual data model I have other tables linked to the 'CALENDAR' table and 'PROJECT_LOOKUP' tables so that I receive this error when I try to change that relationship to 'Both':

 

Error1.PNG

Hi @Anonymous ,

 

Direction is important in relationships,you may try star schema instead.

See the reference below:

https://docs.microsoft.com/en-us/power-bi/guidance/star-schema

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

Modify the direction of the relationship from single to both:

Screenshot 2020-11-20 175859.png

And you will see:

 

Screenshot 2020-11-20 175838.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

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.