Forum Discussion
Tricky divide by "Distinct Count" problem
So below is a sample dataset to help clarify what I'm trying to do. I want to know how much we spent on, say, the "Dog" vendor divided by ALL distinct jobs, regardless of whether we spent money at the dog vendor for other jobs.
So for ex, the Dog average below would be (200+200+388) / 4 (total distinct jobs, 3561, 7898, 8982, 3893) = 197 dog cost / all jobs.
What Power BI seems to want to to do is give me the average of distinct jobs where and only where we had "Dog" vendor cost.
So it doesn't even consider jobs 8982 or 3893. It instead wants to divide by 2 (3561 and 7898).
I've tried experimenting with different DAX formulas but can't seem to get it right. @
Hi Zarlot531 ,
Measure = VAR ave = SUM ( 'Table'[Amount] ) VAR dis = CALCULATE ( DISTINCTCOUNT ( 'Table'[Job] ), ALL ( 'Table' ) ) RETURN DIVIDE ( ave, dis )Please refer to the pbix as attached.
2 Replies
- v-frfei-msftCommunity Support
Hi Zarlot531 ,
Measure = VAR ave = SUM ( 'Table'[Amount] ) VAR dis = CALCULATE ( DISTINCTCOUNT ( 'Table'[Job] ), ALL ( 'Table' ) ) RETURN DIVIDE ( ave, dis )Please refer to the pbix as attached.