cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

use option set for creating collection

Hello,

 

I am trying to add column to my collection.

Is it possible to add column by one formula?

 

I have option set in my CDS. named "products" and I would like to add column for  all item in option set.

  • option set  "products"
  1. Food
  2. Toy
  3. Clothing

ClearCollect(_list,
AddColumns(list,"products",
Sum(Filter('sales',products=????),price)))

 

There are many option set selection so I do not want to do like following.

 

ClearCollect(_list,
AddColumns(list,"Food,
Sum(Filter('sales',products="Food"),price,

"Toy",
Sum(Filter('sales',products="Toy"),price)

"Clothing",
Sum(Filter('sales',products="Clothing"),price))))

 

Someone can help me finding a solution for that?

 

4 REPLIES 4
Highlighted
Memorable Member
Memorable Member

Re: use option set for creating collection

Hi @mssss ,

Please see the way how to Add "All" Option using collection.

VijayTailor_0-1602941127319.png

Thanks,

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."-Vijay

Highlighted
Helper III
Helper III

Re: use option set for creating collection

@VijayTailor 

Thank you for your support.

my question was bad.

Could you please check mu question again?

I just edit my explanation.

Highlighted
Memorable Member
Memorable Member

Re: use option set for creating collection

Hi @mssss ,

Thanks, No issue.

Please see the solution for your Issue, Hope my solution help you to resolve your issue.
if not please let me know, 

First Way - Simply you can sum All the value based on your Product in your Source - 
Code - 

AddColumns(_List,"Food",Sum(Filter(_List,Products.Value="Food"),Price),"Toy",Sum(Filter(_List,Products.Value="Toy"),Price),"Shopping",Sum(Filter(_List,Products.Value="Shopping"),Price))

VijayTailor_0-1603003561665.png

 

Second way is using GroupBy. (If you use the Group by Outcome look like below.)
Code - 

AddColumns(GroupBy(AddColumns(_List,"ProductsSelected",Products.Value),"ProductsSelected","ByProducts"),"TotalAmount",Sum(Sum(Filter(_List,Products.Value=ProductsSelected),Price)))

VijayTailor_1-1603003649915.png

Reference - 

VijayTailor_2-1603003770898.png

Thanks,
Vijay

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."-Vijay




 



Highlighted
Helper III
Helper III

Re: use option set for creating collection

@VijayTailor 

Thank you for your advice.

I'm trying in baby steps and still in the following part but not working.

AddColumns(_List,"ProductsSelected",Products.Value)

Got red underline..

Products seems not working because it shows in black word.

 

AddColumns(GroupBy(AddColumns(_List,"ProductsSelected",Products.Value),"ProductsSelected","ByProducts"),"TotalAmount",Sum(Sum(Filter(_List,Products.Value=ProductsSelected),Price)))

 

 

 

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,805)