Forum Discussion
volfied
5 years agoFrequent Visitor
Integrating DAX result sets into Data Model
I apologize if this is a duplicate post, but I'm pretty sure my first attempt got lost in the ether. Also, this ultimately is a DAX/Excel question, not a DAX/PowerBI question. I hope that's not a pro...
- 5 years ago
I finally solved this. It was dirt simple. I'm embarrassed I didn't come up with it sooner. I just had to alter my SQL query to return a difference between the current and previous row and sum all that up in DAX. My measure wound up just being:
Revenue:=VAR MaxDate = MAX ( qryPipelineUS[day_last_mod] ) RETURN CALCULATE ( SUM ( qryPipelineUS[eveAmtDiff] ), qryPipelineUS[day_last_mod] <= MaxDate )The T-SQL's a little more out of the ordinary, as you have to do partitioning and ROW windows, but it's simple enough once you get used to it.
MAX(eh.amount) OVER ( PARTITION BY ph.pipeline_id, eh.pipeline_event_id ORDER BY ph.pipeline_id, eh.pipeline_event_id, eh.date_rec_copy ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING )
volfied
5 years agoFrequent Visitor
Resorting the data wasn't the problem. Oh well.