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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
puserp
Regular Visitor

transpose some measure/ merge

I have a query resulting in :

[TABLE 1]

Dim1Dim2Dim3Date Measure1Measure 2
axyzabct1m1t1am2t1a
axyzabct2m1t2am2t2a
bbxyzabczt1m1t1bm2t1b
bbxyzabczt2m1t2bm2t2b

 

I want to get the results as

[TABLE 2]

Dim1Dim2Dim3Measure1 t1Measure 2 t1Measure1 t2Measure 2 t2
axyzabcm1t1am2t1am1t2am2t2a
bbxyzabczm1t1bm2t1bm1t2bm2t2b

 

In python that can be done easily with two queries for date 1 and date 2 and then a merge on Dim1 Dim2 DIm 3 with suffixes t1 and t2.
Can I achieve directly my [Table 2] in DAX ?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from @bhanu_gautam , please allow me to provide another insight:

 

Hi @puserp ,

 

Whether the formula works or not depends on whether the measure1, measure2 in the information you provide is a created measure or a specific field in the table. Refer to the following formula:

if measure, try below formula:

Table2 = 
SUMMARIZECOLUMNS (
    'Table'[Dim1],
    'Table'[Dim2],
    'Table'[Dim3],
    "Measure1 t1", CALCULATE ( [Measure1], 'Table'[Date ] = "t1" ),
    "Measure 2 t1", CALCULATE ( [Measure2], 'Table'[Date ] = "t1" ),
    "Measure1 t2", CALCULATE ( [Measure1], 'Table'[Date ] = "t2" ),
    "Measure 2 t2", CALCULATE ( [Measure2], 'Table'[Date ] = "t2" )
)

vkongfanfmsft_0-1714542505567.png

 

if field, try below formula:

Table3 =
SUMMARIZECOLUMNS (
    'Table'[Dim1],
    'Table'[Dim2],
    'Table'[Dim3],
    "Measure1 t1", CALCULATE ( MAX ( 'Table'[M1] ), 'Table'[Date ] = "t1" ),
    "Measure 2 t1", CALCULATE ( MAX ( 'Table'[M2] ), 'Table'[Date ] = "t1" ),
    "Measure1 t2", CALCULATE ( MAX ( 'Table'[M1] ), 'Table'[Date ] = "t2" ),
    "Measure 2 t2", CALCULATE ( MAX ( 'Table'[M2] ), 'Table'[Date ] = "t2" )
)

vkongfanfmsft_1-1714542557692.png

 

Best Regards,
Adamk Kong

 

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
Anonymous
Not applicable

Thanks for the reply from @bhanu_gautam , please allow me to provide another insight:

 

Hi @puserp ,

 

Whether the formula works or not depends on whether the measure1, measure2 in the information you provide is a created measure or a specific field in the table. Refer to the following formula:

if measure, try below formula:

Table2 = 
SUMMARIZECOLUMNS (
    'Table'[Dim1],
    'Table'[Dim2],
    'Table'[Dim3],
    "Measure1 t1", CALCULATE ( [Measure1], 'Table'[Date ] = "t1" ),
    "Measure 2 t1", CALCULATE ( [Measure2], 'Table'[Date ] = "t1" ),
    "Measure1 t2", CALCULATE ( [Measure1], 'Table'[Date ] = "t2" ),
    "Measure 2 t2", CALCULATE ( [Measure2], 'Table'[Date ] = "t2" )
)

vkongfanfmsft_0-1714542505567.png

 

if field, try below formula:

Table3 =
SUMMARIZECOLUMNS (
    'Table'[Dim1],
    'Table'[Dim2],
    'Table'[Dim3],
    "Measure1 t1", CALCULATE ( MAX ( 'Table'[M1] ), 'Table'[Date ] = "t1" ),
    "Measure 2 t1", CALCULATE ( MAX ( 'Table'[M2] ), 'Table'[Date ] = "t1" ),
    "Measure1 t2", CALCULATE ( MAX ( 'Table'[M1] ), 'Table'[Date ] = "t2" ),
    "Measure 2 t2", CALCULATE ( MAX ( 'Table'[M2] ), 'Table'[Date ] = "t2" )
)

vkongfanfmsft_1-1714542557692.png

 

Best Regards,
Adamk Kong

 

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

 

bhanu_gautam
Super User
Super User

@puserp , Try using below method 

 

Table2 =
SUMMARIZECOLUMNS (
'TABLE 1'[Dim1],
'TABLE 1'[Dim2],
'TABLE 1'[Dim3],
"Measure1 t1", CALCULATE ( SUM ( 'TABLE 1'[Measure1] ), 'TABLE 1'[Date] = "t1" ),
"Measure 2 t1", CALCULATE ( SUM ( 'TABLE 1'[Measure2] ), 'TABLE 1'[Date] = "t1" ),
"Measure1 t2", CALCULATE ( SUM ( 'TABLE 1'[Measure1] ), 'TABLE 1'[Date] = "t2" ),
"Measure 2 t2", CALCULATE ( SUM ( 'TABLE 1'[Measure2] ), 'TABLE 1'[Date] = "t2" )
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thanks, I just can't get the syntax to work, it gives me

The column "Measure1" in the table "Table 1" is not found and is not used in this expression

That last one was on me for wrong source of t1 and t2

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.