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

Calculate daily average, formula is giving bad results

I'm trying to calculate an average, per person, per day, however the formula is returning invalid an result.

Here's the formula that I use:

_Avg Invoices per Day = CALCULATE(
	DIVIDE(
		COUNT('Billing Stats'[WO#]),
		DISTINCTCOUNT('Billing Stats'[DateInvoiced]),
		0
	)
)

and this is the data:

VTlDwPw

In the example above, 195, 114, 84 are the amounts of invoices each person created for an entire month. 

195/20 is not 20, 84 / 20 does not equal to 5, etc. I'm thinking that my calculation is off, because the formula takes the billing days count per person, which could differ from one to another. So I basically need to mod my formula to calculate the average based on a total billing days overall, not by how many days someone particular billed for. I hope this makes sense.

 

I tried to tweak the formula to the one below, but I got an error stating that a table of multiple values was supplied where only one is expected:

_Avg Invoices per Day = CALCULATE(
	DIVIDE(
		COUNT('Billing Stats'[WO#]),
		CALCULATE(
			DISTINCTCOUNT('Billing Stats'[DateInvoiced]), 
			FILTER('Billing Stats', ALLSELECTED('Billing Stats'[DateInvoiced]))
		),
		0
	)
)

 

This is what my data table looks like:

nL8bbsP

3 REPLIES 3
Greg_Deckler
Super User
Super User

First, I can't fathom the CALCULATE in your first formula. You can get rid of it. Second, I imagine that your issue is that you want the number of billing dates to remain constant (20) but you have a measure so it is taking context into account for how many billing days there are. This is why your total is correct but not your individual rows. Try something like:

 

_Avg Invoices per Day = 
	DIVIDE(
		COUNT('Billing Stats'[WO#]),
		CALCULATE(DISTINCTCOUNT('Billing Stats'[DateInvoiced]),ALL('Billing Stats')),
		0
	)

This will count all of the billing days each time the measure is calculated, removing any other context.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

It's still giving me inaccurate data

d8Q9WCP

Hi @Anonymous,

 

I think you have add some additional filter on visual level or page level, right?

If this is a case, please share the sample pbix file to test, it will be help for analysis.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.