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 III
Super User III

@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

View solution in original post

2 REPLIES 2
RandyHayes
Super User III
Super User III

@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

View solution in original post

Works great, thank you

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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