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
IssieWissie
Frequent Visitor

Turning columns into rows in DAX

Hi everyone,

 

I'm sure this is a well known topic and I'm aware this is much easier done in Power Query. The issue is that the data I am attempting to pivot is obtained from calculated columns in DAX and I'm not sure if it'd be possible to get this into Power Query.

 

My data looks as follows:

Date 1 Date 2Date 3Hours 
05/06/202312/06/202319/06/202377
05/06/202312/06/2023 

51.2

 

The solution I am looking for looks like:

DateHours
05/06/202377
12/06/202377
19/06/202377
05/06/202351.2
12/06/202351.2

or

DateHours
05/06/2023128.2
12/06/2023128.2
19/06/202377

 

Is it possible to achieve this in DAX?

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

Hi @IssieWissie 

You can refer to the following code

Table 2 =
VAR a =
    SUMMARIZE ( FILTER ( 'Table', [Date 1 ] <> BLANK () ), [Date 1 ], [Hours ] )
VAR b =
    SUMMARIZE (
        FILTER ( 'Table', [Date 2] <> BLANK () ),
        'Table'[Date 2],
        'Table'[Hours ]
    )
VAR c =
    SUMMARIZE (
        FILTER ( 'Table', [Date 3] <> BLANK () ),
        [Date 3],
        'Table'[Hours ]
    )
RETURN
    UNION ( a, b, c )

Output

vxinruzhumsft_0-1686018371459.png

Best Regards!

Yolo Zhu

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

1 REPLY 1
v-xinruzhu-msft
Community Support
Community Support

Hi @IssieWissie 

You can refer to the following code

Table 2 =
VAR a =
    SUMMARIZE ( FILTER ( 'Table', [Date 1 ] <> BLANK () ), [Date 1 ], [Hours ] )
VAR b =
    SUMMARIZE (
        FILTER ( 'Table', [Date 2] <> BLANK () ),
        'Table'[Date 2],
        'Table'[Hours ]
    )
VAR c =
    SUMMARIZE (
        FILTER ( 'Table', [Date 3] <> BLANK () ),
        [Date 3],
        'Table'[Hours ]
    )
RETURN
    UNION ( a, b, c )

Output

vxinruzhumsft_0-1686018371459.png

Best Regards!

Yolo Zhu

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

 

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.