Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
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.
Solved! Go to Solution.
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))
Regards,
Jimmy Tao
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))
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
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
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
Can you share Pic of sample data (small and similar to ur situation) and the expected result in the column side to it...
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
82 | |
81 | |
52 | |
39 | |
35 |
User | Count |
---|---|
95 | |
79 | |
52 | |
49 | |
47 |