Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello!
First Post.
I have data of my country's position on a ranking list.
I need to determine the average of that position for each month separately.
Currently im using:
Promedio = CALCULATE(
AVERAGE(PowerBI[Posición]);
FILTER(PowerBI;
PowerBI[Fecha].[Month]<=EARLIER(PowerBI[Fecha].[Month])
&& PowerBI[Fecha].[Day]<=EARLIER(PowerBI[Fecha].[Day]))
)
But the averages are wrongly calculated.
I also noticed that on the first day of the month if position is 50 the average shows 55.5 which means its carrying values from the previous months.
Please help me fix my formula. Thanks in advance.
Solved! Go to Solution.
Hi @Anonymous ,
We can use the following steps to meet your requirement.
1. Create two calculate columns, one is year, another is month.
Month = MONTH('Table'[Date])
year = YEAR('Table'[Date])
2. Then we can create a measure,
Each month AVG =
var current_month = MAX('Table'[Month])
var Total_value = CALCULATE(SUM('Table'[value]))
var Month_day = CALCULATE(DISTINCTCOUNT('Table'[Date]),FILTER('Table','Table'[Month] = current_month))
return
DIVIDE(Total_value,Month_day)
The result like this,
3. Or we can create a calculate column,
AVG column =
var total_month = CALCULATE(DISTINCTCOUNT('Table'[Date]),FILTER(ALLSELECTED('Table'),'Table'[Month]=EARLIER('Table'[Month])&& 'Table'[year]=EARLIER('Table'[year])))
var current_month = CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),'Table'[Month]=EARLIER('Table'[Month]) && 'Table'[year]=EARLIER('Table'[year])))
return
DIVIDE(current_month,total_month)
The result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
We can use the following steps to meet your requirement.
1. Create two calculate columns, one is year, another is month.
Month = MONTH('Table'[Date])
year = YEAR('Table'[Date])
2. Then we can create a measure,
Each month AVG =
var current_month = MAX('Table'[Month])
var Total_value = CALCULATE(SUM('Table'[value]))
var Month_day = CALCULATE(DISTINCTCOUNT('Table'[Date]),FILTER('Table','Table'[Month] = current_month))
return
DIVIDE(Total_value,Month_day)
The result like this,
3. Or we can create a calculate column,
AVG column =
var total_month = CALCULATE(DISTINCTCOUNT('Table'[Date]),FILTER(ALLSELECTED('Table'),'Table'[Month]=EARLIER('Table'[Month])&& 'Table'[year]=EARLIER('Table'[year])))
var current_month = CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),'Table'[Month]=EARLIER('Table'[Month]) && 'Table'[year]=EARLIER('Table'[year])))
return
DIVIDE(current_month,total_month)
The result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
The second Solution/Formula worked perfectly!
Thank you for you quick response.
I would actually just need the average of the whole month I dont really need it to be daily. So that i can Display this table containing ech month:
Any idea would be appreciated! Thanks.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 55 | |
| 34 | |
| 32 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 75 | |
| 72 | |
| 38 | |
| 35 | |
| 25 |