cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Z_Lukowski
Helper II
Helper II

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 III
Super User III

@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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

5 REPLIES 5
RandyHayes
Super User III
Super User III

@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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

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 III
Super User III

@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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

@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 III
Super User III

@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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (17,157)