cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mrQ
Helper V
Helper V

CDS & GroupBy maniplates collections?

Hey there

 

So I've been playing around with CDS as so far I'm not really convinced. At this time, I'd rather stick to SharePoint as a data source as it seems more reliable. However - and this is probably more likely - I might be doing something wrong.

 

I have created an entity called "Transactions". All the fields in this entity are text fields.

 

My problem is the following:

On App.OnStart I'm executing the following commands:

 

1) ClearCollect(colTransactions, Transactions);

 

So far so good. When I check the colTransactions collection I can see all data the way they should be. However, I'd like to group those transactions by month. That's why I'm adding the second command to the App.OnStart:

 

2) ClearCollect(colMonthsGrouped,GroupBy(AddColumns(Filter(Transactions,'Transaction Type' = "Expense"),"Month",Text('Transaction Date',"[$-en-US]mmmm")),"Month","Transactions"));

 

Once I do that, my colTransactions collection is being manipulated and loses the value for some of the fields. E.g. "name" or "category"

 

See before and after: 

problem-collections.jpg

 

Anyone knows why this is happening?

2 REPLIES 2
Drrickryp
Super User
Super User

Hi @mrQ 

I was also playing around with your formulas and found something interesting that I could not explain.  When I tried to reproduce your issue using a collection obtained from the formula on the button as the Items property of the outer gallery, I got a null set as shown in the gallery on the left.  However, when I used 

 

GroupBy(
    AddColumns(
        Orders,
        "Month",
        Text(
            'Order Date',
            "[$-en-US]mmmm"
        )
    ),
    "Month",
    "Transactions"
)

 

 as the items property of the outer gallery and Transactions as the Items property of the inner gallery, it worked perfectly as shown in the gallery on the right.  I'm not sure why the collection didn't work.

Annotation 2020-05-22 104824.jpg

Ok, I tried again and it worked. I used GroupBy(colOrders,"Month","Transactions") as the Items property for the outer gallery and Transactions as the Items property of the Inner gallery. The formula for the collection is in the button.Annotation 2020-05-23 091753.jpg

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,774)