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
youssefm9
Helper I
Helper I

Formula result as per the selected month filter

I would like to do a formula. 

If I select a certain month in the filter, then it will provide the sum of sales during that month.

However, If i select all months in the filter, I want to get the result of all months divided by 12.

 

How can I get the result for the both scenarios depending on what I select on the months filter?

 

Thanks,

Youssef

1 ACCEPTED SOLUTION

No, you don't need calculate here.

Average ACV = AVERAGEX(DISTINCT('P&L Data'[Month]),sum('P&L Data'[ACV]))





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

Proud to be a Super User!




View solution in original post

13 REPLIES 13
v-xinruzhu-msft
Community Support
Community Support

Hi @youssefm9 

You can create a measure like this:

 

_average = var a=CALCULATE(COUNTAX(DISTINCT('Table'[Month]),[Month]),ALLSELECTED('Table'))
return SUMX(ALLSELECTED('Table'),[Value])/a

 

vxinruzhumsft_0-1672106780391.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 
I have added the word Calculate as per the below and it seems it works... is that logic?
 
Average ACV = AVERAGEX(DISTINCT('P&L Data'[Month]), calculate(sum('P&L Data'[ACV])))
ppm1
Solution Sage
Solution Sage

You can create a measure like this one, which will give the average of all months selected.

 

Monthly Avg = AVERAGEX(DISTINCT(Table[MonthColumn]), [YourMeasure])

 

Pat

 

Microsoft Employee

It is not what i am asking for.

What I am asking for is, if any month is selected, then give me the total. If no month is selected (thus all months selected together), give the the total divided by 12.

Did you try the measure to see if it works? If 1 month selected it will give you the total for that month. If >1 month selected (or all selected), it will give you the average total. Note that a measure is needed (not just SUM, unless it is wrapped in CALCULATE).

Pat

 

Microsoft Employee

 

I tried the below but did not work.
 
Average ACV = AVERAGEX(DISTINCT('P&L Data'[Month]), SUM('P&L Data'[ACV]))
 
where ACV is the amount. Table is P&L Data. 

Ok, then to be more strict:

  • what if user select only two months - do you want to show sum of 2 months divided by 12 (which makes no sanse)? 😄 or maybe 3 months? still - divided by 12?

 

OR

 

do you want:

* if month is no filtered - give me sum of some value

* if month is filtered - give me sum of some value for selected month divided by count of selected month?





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

Proud to be a Super User!




Hey thank you for the reply !

I would go for: * if month is filtered - give me sum of some value for selected month divided by count of selected month?

 

In that case @ppm1 gave you correct answer. For one month it will return the value of this month, but for two it will return the sum of them and divided by 2, which is basicly an average. 🙂

 

Monthly Avg = AVERAGEX(DISTINCT(Table[MonthColumn]), SUM([Some Value]))





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

Proud to be a Super User!




Hello...

Thank you for the reply.

However it is not working from my side. It works if I select one month only. If I select more than one month, it will do sum.

Below is the formula i am using:

 

Average ACV = AVERAGEX(DISTINCT('P&L Data'[Month]), SUM('P&L Data'[ACV]))
 
where ACV is the amount. Table is P&L Data. 

Can you post here an example data to see your issue?





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

Proud to be a Super User!




Hi @bolfri 
 
I have added the word Calculate as per the below and it seems it works... is that logic?
 
Average ACV = AVERAGEX(DISTINCT('P&L Data'[Month]), calculate(sum('P&L Data'[ACV])))

No, you don't need calculate here.

Average ACV = AVERAGEX(DISTINCT('P&L Data'[Month]),sum('P&L Data'[ACV]))





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

Proud to be a Super User!




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.