This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi everyone! How do you convert this querry into DAX?
I want to standardize queuries and was hoping it's possible to have this one as a measure/table(s).
WITH cte_elevation AS (
select well_id, SUM(datum_elevation) * -0.3048 AS elevation
from CD_DATUM
where is_default = 'Y'
group by well_id
)
,cte_plan AS (
SELECT wp.well_id, 'Plan' as Type, (wp.md_to * -0.3048) + elevation AS Depth
,cast(sum(isnull(wp.target_duration,0)) over (partition by wp.well_id order by cast(step_no as smallint)) as int) as hours
,cast(step_no as int) AS OrderBy
FROM dbo.DM_WELL_PLAN_OP wp
JOIN cte_elevation e ON wp.well_id = e.well_id
WHERE target_duration is not null
AND md_to is not null
)
,cte_actual AS (
SELECT d.well_id, 'Actual' AS Type, (d.md_current * -0.3048) + e.elevation AS Depth
,isnull(days_on_location,0) * 24 as hours
,CAST(date_report as int) AS OrderBy
FROM dbo.DM_DAILY d
JOIN cte_elevation e ON d.well_id = e.well_id
)
SELECT * FROM cte_plan
UNION ALL
SELECT * FROM cte_actual
@Anonymous , See if this blog can help you how to build this one
https://www.sqlbi.com/articles/from-sql-to-dax-joining-tables/
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 29 | |
| 27 | |
| 25 | |
| 19 | |
| 14 |
| User | Count |
|---|---|
| 56 | |
| 48 | |
| 37 | |
| 21 | |
| 20 |