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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Average from today back six months

Hi All,

 

I need to do something that is probably super simple but i cant seem to work out how.

 

I have a table that has a column in that represents the level of satisfaction with a service we deliver

 

The management team only want me to report satisfaction for the last six months from the current date.

 

so far i've got this

 

6MONTH = CALCULATE(AVERAGEX(MSF,MSF[Satisfaction]),
                             DATESINPERIOD(MSF[Date],LASTDATE(MSF[Date]),-6,MONTH))

 

but it calculates the average over all of the data and doesnt filter for 6 months. I have a date table in the model should I use that and change the measure to days rather than months.

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi cxputcm,

 

Based on your description, you want to filter the last 6 months in a visual, right?

 

You can modify you measure like this:

6MONTH = CALCULATE(AVERAGEX(MSF,MSF[Satisfaction]),  DATESINPERIOD(MSF[Date], TODAY(),-6,MONTH))

1.PNG2.PNG

 

Regards,

Jimmy Tao

View solution in original post

8 REPLIES 8
v-yuta-msft
Community Support
Community Support

Hi cxputcm,

 

Based on your description, you want to filter the last 6 months in a visual, right?

 

You can modify you measure like this:

6MONTH = CALCULATE(AVERAGEX(MSF,MSF[Satisfaction]),  DATESINPERIOD(MSF[Date], TODAY(),-6,MONTH))

1.PNG2.PNG

 

Regards,

Jimmy Tao

Does this works even if you don't have the today's date in the table?

Out of interest am I missing something? Why is everyone suggesting going down the DAX route when the visual has a filter that can be used?

 

Chris

Anonymous
Not applicable

Hi Chris,

 

Just wanted to confirm the filter method also works but I was looking to build an independant measure that would display dynamically

 

Thanks for your help all, its much appreciated

 

 

@Anonymous No problem Smiley Happy

afzalphatan
Resolver I
Resolver I

DATESINPERIOD  and all other time functions in DAX works well only with "continuous dates in dimension table".......

 

You can create a seperate dimDate table staring with 1st Jan and ends with 31st dec .... make a realationship and use DATESINPERIOD( DimDate, LASTDATE(MSF[Date]),-6,MONTH )

 

HOPES THIS SOLVES UR Prob

afzalphatan
Resolver I
Resolver I

Can  you share Pic of sample data (small and similar to ur situation) and the expected result in the column side to it... 

Chris99
Advocate III
Advocate III

Hi @Anonymous

 

In the Filters section of your table select the date field. In the filter properties select a Filter Type of "Relative date filtering". Then choose "is in the last" and set the value to 6. Change the drop down below it from "days" to "months" or "calendar months" depending on your exact requirement. Click on Apply filter and that should hopefully do the job.

 

Chris

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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