cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Z_Lukowski
Resolver I
Resolver I

Groupby by a Lookup field - giving error "Expected a text, numeric, boolean, or date/time value - even when I use Text() in my lookup

Hello Power Users,

I have a Gallery in which I have a Lookup column ("DogColumn"),

ThisItem.'Dog'.'DogName'

Where 'Dog' is a Lookup column in my Table Shelter(which is source of my Gallery btw)  to Table Dogs, and 'DogName' is primary column there

I want to Groupby my items by 'DogName'

 

So I've created:

Groupby(Gallery_Dogs, "DogColumn", "AnyNameWIlldo") - which should group my records based on DogName

 

but I get error:

"Expected a text, numeric, boolean, or date/time value"

When Ive changed "DogColumn" to Text(ThisItem.'Dog'.'DogName') it did not help, my datatype is text and yet it expects text value in error message:

Z_Lukowski_0-1612971663625.png

 

Of course my Gallery is displaying properly and all the dog names are there, they are correct, based on Lookup field, so the issue is not there.

 

@RandyHayes  - created my new topic following your advice,

 

Would appreciate any kind of help, and wish you good day to all kind Power Users out there 🙂

 

Regards,

Zbigniew

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Z_Lukowski 

Thanks for posting a new thread...it will get more attention.

 

You will not be able to group by a lookup column without a couple steps.

I am assuming (since you mentioned Gallery_Dogs in your formula sample) that you want to Group By the items in your Gallery

 

Your formula should be as follows:

GroupBy(
    AddColumns(
        Gallery_Dogs.AllItems,
        "_dogName", Dog.DogName
    ),
    "_dogName",
    "records"
)
    

This will return a table of grouped dog names and their associated records.

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@Z_Lukowski 

Thanks for posting a new thread...it will get more attention.

 

You will not be able to group by a lookup column without a couple steps.

I am assuming (since you mentioned Gallery_Dogs in your formula sample) that you want to Group By the items in your Gallery

 

Your formula should be as follows:

GroupBy(
    AddColumns(
        Gallery_Dogs.AllItems,
        "_dogName", Dog.DogName
    ),
    "_dogName",
    "records"
)
    

This will return a table of grouped dog names and their associated records.

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

You @RandyHayes are truly my saviour, big online hug 🤗  If you ever in Warsaw leave me a message on forum, and I owe you a round,drink, smoothie or whatever you like. 

RandyHayes
Super User
Super User

@Z_Lukowski 

Happy to help!!  I will certainly keep your invite in mind should I be in the area 😁

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes And what If I would like to count those dog names based on my groupby and Filterout results with Records <>2, example on screenshot, is this even possible?

Z_Lukowski_0-1613049984911.png

 

Best Regards

Zbigniew

 

RandyHayes
Super User
Super User

@Z_Lukowski 

Sure thing, you can add more columns to contain that information:

AddColumns(
    GroupBy(
        AddColumns(
            Gallery_Dogs.AllItems,
            "_dogName", Dog.DogName
        ),
        "_dogName",
        "records"
    ),
    "_dogCount", CountRows(records)
)

 

_dogCount will have the count of the dog names of that group. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

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.

Users online (3,699)