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

 

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,633)