Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
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
@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]))
@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
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
10 | |
6 |