Forum Discussion
Calculating ROI equalizing point in time
- 8 years ago
Hi thschr,
As far as I know, I'm afraid we can't achieve that by DAX. I would suggest you try the R. Please check out the demo in the attachment.
dataset <- dataset[with(dataset, order(Index)),] j <- 1 middle_value <- 0 new_col <- c() nrows_dataset <- nrow(dataset) for (i in c(1: nrows_dataset)) { if (middle_value == 0) { middle_value <- dataset$Cost[i] - dataset$"Net Revenue"[j] j <- j + 1 } else { middle_value <- dataset$Cost[i] + middle_value } while(middle_value > 0 && j <= nrows_dataset) { middle_value <- middle_value - dataset$"Net Revenue"[j] j <- j + 1 } if (middle_value <= 0) { new_col[i] <- as.character(dataset$Month[j - 1]) } else { new_col[i] <- "null" } } result <- cbind(dataset, new_col)Best Regards,
Dale
I was also trying to check on this. BTW do you know a way to export as a table?
We tried with R library tableHtml and didn't work. Could you recommend me how to go on? or if I need another package?
best,
J
Hi Jmenas,
What could be the result of "export as a table"? Usually, we won't export data from the Query Editor. If you'd like to know how to return the result of R to Power BI, you just need to format the result in the type of data.frame of R explicitly like below.
result <- cbind(dataset, new_col)
If this isn't the case, I would suggest you open a new thread in this forum that we can discuss more.
Best Regards,
Dale