cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
caslus
Helper I
Helper I

Converter row to columns by dax in the same table

I have this in my table:

DATELIM FDOLIM FRPUND
26/fev208686A
26/fev9392166B

 

And I need show this like a table in my dashboard:

DATEVALORUNDDES
26/fev208ALIM FDO
26/fev939BLIM FDO
26/fev686ALIM FRP
26/fev2166BLIM FRP

 

I don´t have idea how to do this in DAX, and I need make this in DAX

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

Hi @caslus ,

 

DAX way :

Table 2 =
VAR a =
    SELECTCOLUMNS ( 'Table', "und", 'Table'[UND], "date_", 'Table'[DATE] )
VAR k =
    CROSSJOIN ( { "LIM FDO", "LIM FRP" }, a )
RETURN
    ADDCOLUMNS (
        k,
        "result", IF (
            [Value] = "LIM FDO",
            CALCULATE ( SUM ( 'Table'[LIM FRP] ) ),
            IF ( [Value] = "LIM FRP", CALCULATE ( SUM ( 'Table'[LIM FDO] ) ) )
        )
    )

2.PNG

 

Pbix as attached.

 

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @caslus ,

 

DAX way :

Table 2 =
VAR a =
    SELECTCOLUMNS ( 'Table', "und", 'Table'[UND], "date_", 'Table'[DATE] )
VAR k =
    CROSSJOIN ( { "LIM FDO", "LIM FRP" }, a )
RETURN
    ADDCOLUMNS (
        k,
        "result", IF (
            [Value] = "LIM FDO",
            CALCULATE ( SUM ( 'Table'[LIM FRP] ) ),
            IF ( [Value] = "LIM FRP", CALCULATE ( SUM ( 'Table'[LIM FDO] ) ) )
        )
    )

2.PNG

 

Pbix as attached.

 

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

Greg_Deckler
Super User
Super User

I believe you want to unpivot your two middle columns, like this:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnEMcVXSUfLx9FVwc/GHsYICgKxQPxelWJ1oJSMz/bTUMqCAkYEFkDSzMAOSjqhSlsaWIAWGZiA5J6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"DATE", type text}, {"LIM FDO", Int64.Type}, {"LIM FRP", Int64.Type}, {"UND", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"DATE", "UND"}, "Attribute", "Value")
in
    #"Unpivoted Columns"

@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop!
Microsoft Hates Greg's Quick Measures
Check out my latest book!

This is in power query?

I need made this in DAX, becouse I have anothers columns in my table.

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!