Forum Discussion
Best Approach to Two Dax Challenges?
- 8 years ago
Hi,
Let's solve the first one. Try this
=(CALCULATE(SUM(ConsumptionData2017[Gal (000s)]),ConsumptionData2017[Rate Class]="Residential")/CALCULATE(DISTINCTCOUNT(ConsumptionData2017[Location ID]),ConsumptionData2017[Rate Class]="Residential"))/12
Does this work?
- Anonymous8 years ago
Looks like you're missing a DIVIDE() statement in the first parameter of your CALCULATE() ...
Test Dax := CALCULATE ( DIVIDE ( AVERAGE ( ConsumptionData2017[Gal (000s)] ), DISTINCTCOUNT ( ConsumptionData2017[Location ID] ) ), ConsumptionData2017[Rate Class] = "Residential" )PS...go to www.daxformatter.com to get the nicely formatted code that I've been providing. It's a HUGE help, especially with more complex DAX.
Regarding wanting to see the monthly average in the grand total, you may want to use the following pattern:
IF(
HASONEVALUE( Month ),
[Subtotal measure for 1 month],
[Different measure for calculating in the grand total]
)
There's some good documentation on this already. Check PowerPivotPro's website.
Looks like you're missing a DIVIDE() statement in the first parameter of your CALCULATE() ...
Test Dax :=
CALCULATE (
DIVIDE (
AVERAGE ( ConsumptionData2017[Gal (000s)] ),
DISTINCTCOUNT ( ConsumptionData2017[Location ID] )
),
ConsumptionData2017[Rate Class] = "Residential"
)PS...go to www.daxformatter.com to get the nicely formatted code that I've been providing. It's a HUGE help, especially with more complex DAX.
Regarding wanting to see the monthly average in the grand total, you may want to use the following pattern:
IF(
HASONEVALUE( Month ),
[Subtotal measure for 1 month],
[Different measure for calculating in the grand total]
)
There's some good documentation on this already. Check PowerPivotPro's website.
Thanks, I'll use daxformatter. As to the formula, it generates an answer of 0.00043775. I have no idea what that number represents.