Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now
I need help translating this query to DAX:
select sum(true_total) as physician_values, p.physician_id
from orders as o inner join prescriptions as p
on cast(o.purchased_on as date) <= p.script_end and cast(o.purchased_on as date) >= p.script_start and o.client_id = p.client_id
group by p.physician_id;
I tried using DirectQuery but I was having trouble slicing the data by date.
Hi @dennis_yin,
The measure could be like below. If you need a more precise solution, please provide a dummy sample.
The o.client_id = p.client_id part will be achieved by the relationship.
Measure =
CALCULATE (
SUM ( orders[true_total] ),
FILTER (
orders,
orders[purchased_on] <= MIN ( prescriptions[script_end] )
&& orders[purchased_on] >= MIN ( prescriptions[script_start] )
)
)
Best Regards,
Dale
Thanks for the reply Dale, but I realize now that I didn't properly explain what I'm trying to do. I need the sum of orders[true_total] for each unique physician, and I need to be able to filter valid prescriptions by a given date. So then if a user chooses September 1 with the date slicer, the true_total value for each physician only reflects prescriptions with a start date <= September 1, and an expiry date >= September 1.
Hi @dennis_yin,
Please share a dummy sample.
Best Regards,
Dale
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 52 | |
| 44 | |
| 44 | |
| 20 | |
| 19 |
| User | Count |
|---|---|
| 71 | |
| 70 | |
| 34 | |
| 33 | |
| 31 |