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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Average count by day when there are blanks

I am working on the visual below and am having an issue with the total for the average count column bring incorrect.  I know it has to do with the presence of blanks, but am not sure how to get it to work correctly.

 

ADB8335_0-1708535385420.png

As you can see, the black account has records for all 4 days but the purple account only has records for 3 days.  The average count for each line is correct, but as you can see the total line is incorrect.  It should be 31.5 ( (18 + 40 + 34 + 34) / 4).  The DAX for my measure is below and I am using AVERAGEX, which I know ignores blanks.  I have also tried using HASONEFILTER, to try and calculate the total line differently from the detail lines, but I am unable to get it to work.  Any help is appreciated.

 

_Measure =
var FilterRecordStartDate= MIN('Date'[Date])
VAR FilterRecordEndDate = MAX('Date'[Date])
VAR results =
AVERAGEX(VALUES('Date'[Date]),
CALCULATE (DISTINCTCOUNT( 'Table1'[Table1_Key])
,Table2[RecordStartDate] <= FilterRecordEndDate
,OR(Table2[RecordEndDate] >= FilterRecordStartDate, ISBLANK(Table2[RecordEndDate]))
,USERELATIONSHIP('Table2'[Table2_Key], 'Table1'[Table2_Key]) )
)
RETURN results

2 REPLIES 2
Anonymous
Not applicable

@Greg_Deckler  Thanks for the help on this.  For the report I am working on, I don't need to show the totals at the bottom of the table I have shown above, but I do need to show the total on a card.  If I use the DAX below, it is painfully slow, due to the amount of data we have.  Is there a way to just get the sum of the Average Count measure without needing to summarize the data by account or at a row level before the measure sums it?  Ideally I would like to use SUM(Average Count), but I know you cannot use a measure in the SUM function.

 

 

Here is the measure that I currently have, but like I said it is very slow.

 

VAR total = SUMMARIZE('Table1',[Account],"_total",[Average Count])
RETURN
IF(HASONEVALUE('Table1'[Account]),[Average Count],SUMX(total,[_total]))

Greg_Deckler
Community Champion
Community Champion

@Anonymous First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.