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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Shams7
New Member

Multiples columns in 1 calculated table

I have 1 table where there is 6 columns in 1 table like below

IDLegalDPITOpsComp
ABCInFlowOutFlowInFlowInFlowMissing
EFGOutFlowInflowOutFlowOutFlowMissing
IJKMissingInflowMissingOutFlowMissing
LMNInflowInflowMissingOutFlow

Missing

 

And i want to calculate new table like below.

IDType
ABCInFlow
EFGOutFlow
IJKMissing
LMNInflow
ABCOutFlow
EFGInflow
IJKInflow
LMNInflow
ABCInFlow
EFGOutFlow
IJKMissing
LMNMissing
ABCInFlow
EFGOutFlow
IJKOutFlow
LMNOutFlow
ABCMissing
EFGMissing
IJKMissing
LMNMissing

 

Can i do it like this, thanks in advance

 

 

1 ACCEPTED SOLUTION

@Shams7 

To create a table using DAX, here is the code. Replace Table04 with your table name.

New Table Name = 
	UNION(
		SELECTCOLUMNS('Table04', "ID", 'Table04'[ID], "Type", 'Table04'[Legal]),
		SELECTCOLUMNS('Table04', "ID", 'Table04'[ID], "Type", 'Table04'[DP]),
		SELECTCOLUMNS('Table04', "ID", 'Table04'[ID], "Type", 'Table04'[IT]),
		SELECTCOLUMNS('Table04', "ID", 'Table04'[ID], "Type", 'Table04'[Ops]),
		SELECTCOLUMNS('Table04', "ID", 'Table04'[ID], "Type", 'Table04'[Comp])
	)
	

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

5 REPLIES 5
ThxAlot
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyVtJR8sxzy8kvBzL8S0ugLLgQnOGbWVycmZeuFKsTreTq5o6mOg3dAAQLWaOnlzeSCJJGhBB2jT6+fsjKidMXCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Legal = _t, DP = _t, IT = _t, Ops = _t, Comp = _t]),

    #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
    #"Unpivoted Other Columns" = Table.RemoveColumns(Table.UnpivotOtherColumns(#"Added Index", {"Index"}, "Id", "Type"), {"Index"})
in
    #"Unpivoted Other Columns"

ThxAlot_0-1702630980571.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



This will not feasible as all other columns except ID is calculated columns, please suggest another way

Fowmy
Super User
Super User

@Shams7 

Use Power Query to do it using UnPivot functionality: https://www.youtube.com/watch?v=IULqUeYEnto&pp=ygUJZXhjZWxmb3J0


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

This will not feasible as all other columns except ID is calculated columns, please suggest another way

@Shams7 

To create a table using DAX, here is the code. Replace Table04 with your table name.

New Table Name = 
	UNION(
		SELECTCOLUMNS('Table04', "ID", 'Table04'[ID], "Type", 'Table04'[Legal]),
		SELECTCOLUMNS('Table04', "ID", 'Table04'[ID], "Type", 'Table04'[DP]),
		SELECTCOLUMNS('Table04', "ID", 'Table04'[ID], "Type", 'Table04'[IT]),
		SELECTCOLUMNS('Table04', "ID", 'Table04'[ID], "Type", 'Table04'[Ops]),
		SELECTCOLUMNS('Table04', "ID", 'Table04'[ID], "Type", 'Table04'[Comp])
	)
	

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.