cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Boynog
Helper II
Helper II

Replicate more data to to a columns

Hi Everyone,

 

How can I get the data that more duplicate in a columns to put it to another columns?

I have an existing data collection.

Boynog_0-1616828562456.png

and How can I put the highlighted data to the other columns that look like this.

Boynog_1-1616828686323.png

 

Thank you and best regards,

Boynogs,

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-albai-msft
Community Support
Community Support

Hi @Boynog ,

Are you using a Table or a gallery?

The key of your requirement is to get the exactly value(for example, "Television"), if you get this value, you can then use this value to populate different columns. You can try below solution.

Add a button, set its OnSelect to below formula(or you can put this formula into the OnStart property of your app, remember to replace to the name of your DataSource): 

 

ClearCollect(test1,Distinct(DataSource,Work));
ClearCollect(test2,ForAll(test1,CountRows(Filter(DataSource,Work=Result))));
Clear(Combined);
ForAll(
Sequence(CountRows(test1)),
Collect(Combined,
{
Work:Last(FirstN(test1,Value)).Result,
count:Last(FirstN(test2,Value)).Value
})
);
Set(var1,First(SortByColumns(Combined,"count",Descending)).Work)

 

This is the result of collection Combined:

v-albai-msft_0-1617004836193.png

 

This time, the needed value is saved in the variable "var1". If you are using a gallery, you can directly use var1 for different labels.

For example, I am using a gallery, I add a label and set its Text=var1:

v-albai-msft_1-1617004653254.png

And set another label to If(ThisItem.Work=var1,var1,"No Data"):

v-albai-msft_2-1617004686953.png

Best regards,

Allen

 

View solution in original post

1 REPLY 1
v-albai-msft
Community Support
Community Support

Hi @Boynog ,

Are you using a Table or a gallery?

The key of your requirement is to get the exactly value(for example, "Television"), if you get this value, you can then use this value to populate different columns. You can try below solution.

Add a button, set its OnSelect to below formula(or you can put this formula into the OnStart property of your app, remember to replace to the name of your DataSource): 

 

ClearCollect(test1,Distinct(DataSource,Work));
ClearCollect(test2,ForAll(test1,CountRows(Filter(DataSource,Work=Result))));
Clear(Combined);
ForAll(
Sequence(CountRows(test1)),
Collect(Combined,
{
Work:Last(FirstN(test1,Value)).Result,
count:Last(FirstN(test2,Value)).Value
})
);
Set(var1,First(SortByColumns(Combined,"count",Descending)).Work)

 

This is the result of collection Combined:

v-albai-msft_0-1617004836193.png

 

This time, the needed value is saved in the variable "var1". If you are using a gallery, you can directly use var1 for different labels.

For example, I am using a gallery, I add a label and set its Text=var1:

v-albai-msft_1-1617004653254.png

And set another label to If(ThisItem.Work=var1,var1,"No Data"):

v-albai-msft_2-1617004686953.png

Best regards,

Allen

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,351)