Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jesly_ajin
Helper III
Helper III

Convert SQL Query to DAX or Power Query

Dear All,

 

Kindly help me create below SQL Query to DAX or Power Query in Power BI.

I am completely new to this. Truely appreciate your help.

 

SELECT t2.Transdate, t2.HOURREADINGS AS MinHourReading,
t3.Transdate, t3.HOURREADINGS AS MaxHourReading
, abs(t3.HOURREADINGS - t2.HOURREADINGS) as MonthlyReading
, t1.EquipmentNo, t3.projid
FROM
( SELECT EquipmentNo, min(Transdate) as minTransDate, max(Transdate) as maxTransDate
FROM [dbo].[LTFUELJOURNALHISTORY]
WHERE EquipmentNo = 'G15_05' --and Transdate between '2019-08-01' and '2019-08-31'
GROUP BY EquipmentNo, MONTH(Transdate), YEAR(Transdate)
) AS t1
JOIN [dbo].[LTFUELJOURNALHISTORY] AS t2 ON t2.Transdate = t1.minTransDate and t1.EquipmentNo = t2.EquipmentNo
JOIN [dbo].[LTFUELJOURNALHISTORY] AS t3 ON t3.Transdate = t1.maxTransDate and t1.EquipmentNo = t3.EquipmentNo
ORDER BY t1.EquipmentNo, YEAR(t3.Transdate), MONTH(t3.Transdate)

0 REPLIES 0

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.