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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ludvigreck
Frequent Visitor

Transformation help in Fabric Data Warehouse

Hello,

 

Can anyone help me with "translating" this DAX code, so the transformation can happen at the data warehouse-level?

 

ludvigreck_0-1724223026222.png

 

TIA,

 

Ludvig Reck

1 ACCEPTED SOLUTION
v-nuoc-msft
Community Support
Community Support

Hi @ludvigreck 

 

I misunderstood your question, please let me try to help you again.

 

Translating DAX code to SQL for data warehouse-level transformations involves converting the logic and functions used in DAX to their SQL equivalents. 

 

 

WITH CTE AS (
    SELECT 
        [Appointment Time] AS minDate,
        Duration AS dur,
        LEAD([Appointment Time]) OVER (ORDER BY [Appointment Time]) AS nextStart
    FROM 
        Query
)
SELECT 
    minDate,
    dur,
    CASE 
        WHEN nextStart IS NOT NULL THEN DATEDIFF(MINUTE, minDate, nextStart)
        ELSE NULL
    END AS [Time Diff calc]
FROM 
    CTE

 

 

 

This SQL query should help you achieve the same transformation at the data warehouse level.

 

Here is the result.

 

vnuocmsft_0-1724310597727.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-nuoc-msft
Community Support
Community Support

Hi @ludvigreck 

 

I misunderstood your question, please let me try to help you again.

 

Translating DAX code to SQL for data warehouse-level transformations involves converting the logic and functions used in DAX to their SQL equivalents. 

 

 

WITH CTE AS (
    SELECT 
        [Appointment Time] AS minDate,
        Duration AS dur,
        LEAD([Appointment Time]) OVER (ORDER BY [Appointment Time]) AS nextStart
    FROM 
        Query
)
SELECT 
    minDate,
    dur,
    CASE 
        WHEN nextStart IS NOT NULL THEN DATEDIFF(MINUTE, minDate, nextStart)
        ELSE NULL
    END AS [Time Diff calc]
FROM 
    CTE

 

 

 

This SQL query should help you achieve the same transformation at the data warehouse level.

 

Here is the result.

 

vnuocmsft_0-1724310597727.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-nuoc-msft
Community Support
Community Support

Hi @ludvigreck 

 

VAR star = SELECTEDVALUE('Table'[Appointment Time]) // Query the date/time of the current row.

 

VAR DUR = SELECTEDVALUE('Table'[Duration]) // Query the Duration of the current row.

 

VAR nextStar = 
    CALCULATE(
        MIN('Table'[Appointment Time]),
        ALLSELECTED('Table'),
        'Table'[Appointment Time] > star
    )                                    // Query the next date/time.

 

VAR TimeDiff = DATEDIFF(star, nextStar, MINUTE) //Query star and nextstar minute difference

 

VAR final = 
    IF(
        TimeDiff < DUR,
        TimeDiff, 
        DUR
    ) 
// If timediff is less than the current duration, return timediff. Otherwise, duration is returned.

 

RETURN final //Return the final result.

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello Nono Chen, you have posted the exact same DAX code as I provided ( ? )

 

To my understanding, this is not supported as a query language in Fabrics' Data Warehouse. I need this in a query languange so that I'm able to make this transformation at the Data Warehouse-level.

 

// Ludvig

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

JanFabricDE_carousel

Fabric Monthly Update - January 2025

Explore the power of Python Notebooks in Fabric!

JanFabricDW_carousel

Fabric Monthly Update - January 2025

Unlock the latest Fabric Data Warehouse upgrades!

JanFabricDF_carousel

Fabric Monthly Update - January 2025

Take your data replication to the next level with Fabric's latest updates!