Forum Discussion
WishAskedSooner
Continued Contributor
2 years agoDividing and Excluding when No Entries
I have a narrow fact table similar to the following: It is joined on the following dimension table: My goal is to calculate the average Discount by Quantity, however making sure not to ...
- 2 years ago
Avg Disc By Qty = var a = intersect(SELECTCOLUMNS(filter('Table',[AID]=1),[OID]),SELECTCOLUMNS(filter('Table',[AID]=2),[OID])) return divide(CALCULATE(sum('Table'[VALUE]),'Table'[AID]=1,'Table'[OID] in a),CALCULATE(sum('Table'[VALUE]),'Table'[AID]=2,'Table'[OID] in a),0)
lbendlin
Super User
2 years ago
Avg Disc By Qty =
var a = intersect(SELECTCOLUMNS(filter('Table',[AID]=1),[OID]),SELECTCOLUMNS(filter('Table',[AID]=2),[OID]))
return divide(CALCULATE(sum('Table'[VALUE]),'Table'[AID]=1,'Table'[OID] in a),CALCULATE(sum('Table'[VALUE]),'Table'[AID]=2,'Table'[OID] in a),0)
WishAskedSooner
Continued Contributor
2 years agolbendlin Thank you so much for your quick solution! I am not sure why, but division with DAX seems way harder than it should be. Kudos!