Forum Discussion
leroy773
10 years agoHelper II
Calculate duration based on dates in different rows.
All, I am attempting to see if Power BI is a good fit. And trying to get started on reporting. I have data from salesforce I reported in the query. I am looking for an easy way to show the dur...
- Anonymous10 years ago
Hi leroy773,
Based on your description, you want to compare your current row with previous row, right? If that is the case, firstly, go to query editor of Power BI Desktop and add an index column in your current table.
Secondly, add a new column and write DAX formula to compare date values of the rows.Duration = DATEDIFF(Table5[Column1],IF(Table5[Index]=0,Table5[Column1],LOOKUPVALUE(Table5[Column1],Table5[Index],Table5[Index]-1)),HOUR)/24
For more details, you can review the example in the attached PBIX file.
Thanks,
Lydia Zhang
CahabaData
10 years agoMemorable Member
I don't follow what you mean by 'calculate' ..... but Lydia gave method in post on how to join another row's value using LookupValue and (Index-1)
not sure if the right solution is -1 or +1 but in any case it is the concept to use
leroy773
10 years agoHelper II
Thanks got everything working now, just need to fine tune the query