Forum Discussion
Divide two columns DAX
- 8 years ago
Hello all,
Thank you for you efforts. I finally found the solution.
What I needed to do was:
- create three measures:
Sale = SUM(Query1[SALES])*100
PlannedSale = SUM(Query1[PLANNED_SALES])
Percentage= DIVIDE([Sale];[PlannedSale])
Only this way worked for me and it is cool. Thank you guys
When I put formula like this:
PercentDifference= DIVIDE('Query1'[SALES]*100; 2 )There is no error, and the column PercentDifference returns result just fine.
But, I need to put in the formula like this:
PercentDifference= DIVIDE('Query1'[SALES]*100; Query1[PLANNED_SALE] )In this case, the column PercentDifference is EMPTY. Like in the image:
Why, when I put second parameter (planned_sale) the result is nothing? But if I put number 2, it is fine
Right now I am testing:
I cannot even do this:
PERCENT_DIFFERENCE = DIVIDE(Query1[SALES]; Query1[PLANNED_SALE] )
Result is also EMPTY column, not zero, nor anything, just empty. Does it mean that DIVIDE function cannot divide two columns?
- Phil_Seamark8 years agoMicrosoft Employee
HI volkanbygl
What happens if you try a different operator.
PERCENT_DIFFERENCE_test = Query1[SALES] + Query1[PLANNED_SALE]
or even this
PERCENT_DIFFERENCE_test2 = Query1[SALES]
or
PERCENT_DIFFERENCE_test4 = Query1[PLANNED_SALE]
finally
PERCENT_DIFFERENCE_test = Query1[SALES] / Query1[PLANNED_SALE]
Are Query1[Sales] and Query1[Planned_sale] both physical columns, and not calculated columns or measures?
What does the column show in the Data View? Rather than using a visual
- volkanbygl8 years agoRegular Visitor
Hello,
thank you for being there.
What happens if you try a different operator.
PERCENT_DIFFERENCE_test = Query1[SALES] + Query1[PLANNED_SALE]
with plus operator, the result is good.
or even this
PERCENT_DIFFERENCE_test2 = Query1[SALES]
with assigning it 'copies' just fine
or
PERCENT_DIFFERENCE_test4 = Query1[PLANNED_SALE]
finally
PERCENT_DIFFERENCE_test = Query1[SALES] / Query1[PLANNED_SALE]
BUT, with / operator I get infinity in every row in a column
When I put * operator, the column is empty
what could it be?
- Phil_Seamark8 years agoMicrosoft Employee
Sorry to keep suggesting tests but how about this one
PERCENT_DIFFERENCE_test5 = IFERROR( Query1[SALES] / Query1[PLANNED_SALE] , -1)