cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

How to concat a column row values into string (label to display all the values realted to a field value)

Hi Team,

how to loop column values and extract them into a text(in one row) separated by coma, based on the city.

we have a table 

CityVillages
c1v1
c1v2
c1v3
c2v1
c2v2
c3v1

Expected values in the gallery like 

CityVill
c1v1,v2,v3
c2v1,v2,
c3v1
  

 

Please help me.
your reply is really appreciated with example. 
@v-bofeng-msft 

1 ACCEPTED SOLUTION

Accepted Solutions
v-chengfen-msft
Microsoft
Microsoft

Hi @muralikrishna12 ,

 

I've made a test for your reference:

 

I assume there is a table


ClearCollect(

    ComTest,

    {City:"c1",Vill:"v1"},

    {City:"c1",Vill:"v2"},

    {City:"c1 ",Vill:"v3"},

    {City:"c2",Vill:"v1"},

    {City:"c2",Vill:"v2"},

    {City:"c3",Vill:"v1"}

)

 

Add a Gallery and set it's items property to:

GroupBy(ComTest,"City","New")

vchengfenmsft_0-1667207365217.png

 

 

Add a Label in Gallery and set it's Text property to:

If(

    CountRows(ThisItem.New) > 1,

    Left(

        Concat(

            Filter(

                ComTest,

                City = ThisItem.City

            ),

            Vill & ", "

        ),

        Len(

            Concat(

                Filter(

                    ComTest,

                    City = ThisItem.City

                ),

                Vill & ", "

            )

        ) - 2

    ),

    First(

        Filter(

            ComTest,

            City = ThisItem.City

        )

    ).Vill

)

vchengfenmsft_1-1667207365221.png

 

Best Regards

Cheng Feng

 

View solution in original post

1 REPLY 1
v-chengfen-msft
Microsoft
Microsoft

Hi @muralikrishna12 ,

 

I've made a test for your reference:

 

I assume there is a table


ClearCollect(

    ComTest,

    {City:"c1",Vill:"v1"},

    {City:"c1",Vill:"v2"},

    {City:"c1 ",Vill:"v3"},

    {City:"c2",Vill:"v1"},

    {City:"c2",Vill:"v2"},

    {City:"c3",Vill:"v1"}

)

 

Add a Gallery and set it's items property to:

GroupBy(ComTest,"City","New")

vchengfenmsft_0-1667207365217.png

 

 

Add a Label in Gallery and set it's Text property to:

If(

    CountRows(ThisItem.New) > 1,

    Left(

        Concat(

            Filter(

                ComTest,

                City = ThisItem.City

            ),

            Vill & ", "

        ),

        Len(

            Concat(

                Filter(

                    ComTest,

                    City = ThisItem.City

                ),

                Vill & ", "

            )

        ) - 2

    ),

    First(

        Filter(

            ComTest,

            City = ThisItem.City

        )

    ).Vill

)

vchengfenmsft_1-1667207365221.png

 

Best Regards

Cheng Feng

 

Helpful resources

Users online (4,161)