Forum Discussion
Divide one column by another
- 10 years ago
Cheers for all the help people.
Unfortunately couldnt manage to get the answer I wanted with the calculations recommended.
Did however manage to connect to an SQL view that was written with the right data in it.
Didn't know that was possible but all working well now.
ED.
Assuming you have a measure:
NumberOfLoads = CALCULATE(COUNT(JobRuns[RunID]))
Then try this as a measure:
Number Of Loads Divided By Docket = SUMX(JobRuns, [NumberOfLoads] / COUNTROWS(RELATEDTABLE(JobRunDocket)))
The SUMX in this case is because, if you are looking at total number of runs for a day, you want to look at each individual run and divide it by the corresponding number of dockets. You don't want to count the total number of runs and divide it by the total number of corresponding dockets.
If you're trying to do a column rather than a measure, then you don't need the SUMX part:
Number Of Loads Divided By Docket Column = [NumberOfLoads] / COUNTROWS(RELATEDTABLE(JobRunDocket))
I would recommend using the divide()-formula instead of "/", as it has error-handling included.
- leonardmurphy10 years agoSkilled Sharer
Excellent point. I always forget that until I get a divide by zero error.
- elliotdixon10 years agoResponsive Resident
Cheers for all the help people.
Unfortunately couldnt manage to get the answer I wanted with the calculations recommended.
Did however manage to connect to an SQL view that was written with the right data in it.
Didn't know that was possible but all working well now.
ED.- Amir25509 years agoFrequent Visitor
newcolName =
DIVIDE(
SUM('table1'[col1]),
SUM('table1'[col2])
)