cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Fredrik_V
New Member

Multiple column split into rows

Looking for a way to split multiple columns into rows.

Example input collection looks like this:

PowerBi1.JPG

 

And output collection should be:

PowerBi2.JPG

 

Anyone knows if its possible?

And if doable handle if value is missing (missing values zero or null)

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Fredrik_V 

Sure thing.

Consider the following formula:

ClearCollect(colFredrik,
    {Title:"Case1", Status:"yes,no", Active:"yes,no", Week:"1,2"},
    {Title:"Case2", Status:"yes,yes,yes,yes,no,no", Active:"yes,yes,yes,yes,yes,yes,yes", Week:"38,39,40,41,42,43"}
);

Clear(colFredrik2);

ForAll(colFredrik,
    With({statuses:Split(Status, ","), actives:Split(Active, ","), weeks:Split(Week, ",")},
        With({statCount:CountRows(statuses), activeCount:CountRows(actives), weeksCount:CountRows(weeks)},

            ForAll(Sequence(Max(statCount, activeCount, weeksCount)),
                Collect(colFredrik2,
                    {Title: Title,
                     V: Text(Value) & "/" & Text(statCount),
                     Status: If(Value>statCount, "", Last(FirstN(statuses, Value)).Result),
                     Active: If(Value>activeCount, "", Last(FirstN(actives, Value)).Result),
                     Week: If(Value>weeksCount, 0, Value(Last(FirstN(weeks, Value)).Result))
                    }
                )
            )
        )
    )
)

 

You'll notice that I also added an extra "yes" to the second Active record.  This will produce a blank for Status and a 0 for Week.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@Fredrik_V 

Sure thing.

Consider the following formula:

ClearCollect(colFredrik,
    {Title:"Case1", Status:"yes,no", Active:"yes,no", Week:"1,2"},
    {Title:"Case2", Status:"yes,yes,yes,yes,no,no", Active:"yes,yes,yes,yes,yes,yes,yes", Week:"38,39,40,41,42,43"}
);

Clear(colFredrik2);

ForAll(colFredrik,
    With({statuses:Split(Status, ","), actives:Split(Active, ","), weeks:Split(Week, ",")},
        With({statCount:CountRows(statuses), activeCount:CountRows(actives), weeksCount:CountRows(weeks)},

            ForAll(Sequence(Max(statCount, activeCount, weeksCount)),
                Collect(colFredrik2,
                    {Title: Title,
                     V: Text(Value) & "/" & Text(statCount),
                     Status: If(Value>statCount, "", Last(FirstN(statuses, Value)).Result),
                     Active: If(Value>activeCount, "", Last(FirstN(actives, Value)).Result),
                     Week: If(Value>weeksCount, 0, Value(Last(FirstN(weeks, Value)).Result))
                    }
                )
            )
        )
    )
)

 

You'll notice that I also added an extra "yes" to the second Active record.  This will produce a blank for Status and a 0 for Week.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Works great, thank you

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,918)