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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to change the structure of a dataset ?

Hi,

 

I have data set for different cases which are on different stages and I am trying to change the structure of the dataset (required outcome).

It is not necessary that stages name are fixed. Any idea on this would be really helpful.

 

 

Available Dataset      
CaseIDStage NameStage Starting Date    
1A12.1.2019    
2A2.2.2019    
2B11.1.2019    
3C31.3.2019    
4A1.4.2019    
4B15.4.2019    
4C1.5.2019    
5A1.6.2019    
5D1.7.2019    
       
       
Required Outcome      
CaseIDStage 1Stage 2Stage 3Stage 4Stage 5 
1A     
2AB    
3C     
4ABC   
5AD    
       
       

 

Best Regards,

ankbaner

1 ACCEPTED SOLUTION
RobbeVL
Impactful Individual
Impactful Individual

Hi ,

 

Please check the Advanced code below, this should do the trick:

 

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XcxBDoAwCATAv3BuiNCi8ajtL0j//w2RVCse9jLZXVUgSHBYiJGQF9qhJwUeysgRz7tK32o2qZZMmKeW5xZLRD+Qv1avykR592vE5rgN7Bc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [CaseID = _t, #"Stage Name" = _t, #"Stage Starting Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Stage Starting Date", type date}, {"CaseID", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Stage Name.1", each "Stage"&" "&[CaseID]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"CaseID"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[#"Stage Name.1"]), "Stage Name.1", "Stage Name")
in
    #"Pivoted Column"

 

 

Let me know if you need help imlementing this in your model.

 

see liink to example file: 

https://drive.google.com/file/d/13pezcriz3fkX0UAOJKDuAyObJ8IEeV_K/view?usp=sharing 

 

Regards,

 

Robbe  

View solution in original post

2 REPLIES 2
RobbeVL
Impactful Individual
Impactful Individual

Hi ,

 

Please check the Advanced code below, this should do the trick:

 

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XcxBDoAwCATAv3BuiNCi8ajtL0j//w2RVCse9jLZXVUgSHBYiJGQF9qhJwUeysgRz7tK32o2qZZMmKeW5xZLRD+Qv1avykR592vE5rgN7Bc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [CaseID = _t, #"Stage Name" = _t, #"Stage Starting Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Stage Starting Date", type date}, {"CaseID", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Stage Name.1", each "Stage"&" "&[CaseID]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"CaseID"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[#"Stage Name.1"]), "Stage Name.1", "Stage Name")
in
    #"Pivoted Column"

 

 

Let me know if you need help imlementing this in your model.

 

see liink to example file: 

https://drive.google.com/file/d/13pezcriz3fkX0UAOJKDuAyObJ8IEeV_K/view?usp=sharing 

 

Regards,

 

Robbe  

deeksha
Helper II
Helper II

make different calculated columns with required stage names.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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