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.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

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

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,559)