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
JP-Ronse
Helper II
Helper II

merge rows

Hi,

 

A bookkeeping application generates an export that looks as:

 

2017-12-30 14_36_44-Book1 - Excel.png

 

What I need is:

 

2017-12-30 14_28_41-Book1 - Excel.png

 

Is this possible?

 

Kind regards,

 

JP-Ronse

1 ACCEPTED SOLUTION

Conceptually, queries shape unstructured data into tables. Next, DAX (and visuals) may kick in for further data analysis, like aggregation and (filter) context sensitive calculations.

 

So, in this specific case, I would recommend a Power Query solution, even though it can also be done with DAX (in combination with visuals).

Specializing in Power Query Formula Language (M)

View solution in original post

12 REPLIES 12
MarcelBeug
Community Champion
Community Champion

In the Query Editor, make sure the table columns are of type text, then fill down the first column, group by the first column, specifying a dummy operation for Head_2 (e.g. Max) and then adjust the generated code to have the text combined:

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Head_1", type text}, {"Head_2", type text}}),
    #"Filled Down" = Table.FillDown(#"Changed Type",{"Head_1"}),
    #"Grouped Rows" = Table.Group(#"Filled Down", {"Head_1"}, {{"Head_2", each Text.Combine(_[Head_2]," "), type text}})
in
    #"Grouped Rows"
Specializing in Power Query Formula Language (M)

Conceptually, queries shape unstructured data into tables. Next, DAX (and visuals) may kick in for further data analysis, like aggregation and (filter) context sensitive calculations.

 

So, in this specific case, I would recommend a Power Query solution, even though it can also be done with DAX (in combination with visuals).

Specializing in Power Query Formula Language (M)
Zubair_Muhammad
Community Champion
Community Champion

HI @JP-Ronse

 

Try this.

 

First Use the Query Editor to fill down the Blank Cells

 

1080.png


Regards
Zubair

Please try my custom visuals

@JP-Ronse

 

Now you can use this MEASURE to concatenate the HEAD 2

 

Head_2 Measure =
IF (
    HASONEVALUE ( Table1[Head_1] ),
    CONCATENATEX ( Table1, Table1[Head_2], " " )
)

Regards
Zubair

Please try my custom visuals

Hi Zubair_Muhammad,

 

Thanks for the swift reply! I am a learning newby with a long way to go (I'm afraid). Can you explain how to add a Measure?

 

Kind regards,

 

JP-Ronse

@JP-Ronse

 

You can add it from the Modelling Tab or by right clicking the Table fields

The picture below shows this

 

1090.png


Regards
Zubair

Please try my custom visuals

Hi Zubair_Muhammad,

 

I am using excel 2013 with the Power Query add-in and I don't find this option. I tried with a custom column but it doen't accept the formula. Maybe it is just not possible with my configuration.

 

Kind regards,

 

JP-Ronse

Luckily you still have the recommended Power Query solution. Man Wink

Specializing in Power Query Formula Language (M)

Dag Marcel,

 

Can you recommend some reading to get more familiar with PQ?

 

Prettig eindejaarsfeest.

 

JP-Ronse

Dankjewel, insgelijks. (Thanks, likewise)

 

With regard to readings: sometimes I publish video's about specific Power Query subjects on my YouTube channel and I recently published a Power Query (M) Functions dashboard.

 

Otherwise you can find learning resources on http://www.thebiccountant.com/learning-resources/

 

Specializing in Power Query Formula Language (M)

Thanks.

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.