cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SaeedKamel
Frequent Visitor

Get distinct from 2 columns and sum the unique values

Hi Everyone

I have the below database and i want to to put it in a gallery that each section of this gallery has the name of the Department and the unique sum of the employee of each Department  

Table1: to get the name of each department into the gallery using ThisItem 

THDepartmentTHBudgetId
MarketingB
TechnologyC
AccountingE
HRH

 

this to get the calculations

EmpIDTHDepartmentTHBudgetId
553CareC
226TechnologyC
779CareC
553CareC
226TechnologyC
2210CareC
553CareC
5 REPLIES 5
WarrenBelz
Super User
Super User

Hi @SaeedKamel ,

Try the below, however the output of GroupBy is limited by Delegation, so it may not give you the totals you need.

AddColumns(
   GroupBy(
      YourListName,
      "THDepartment",
      "THBudgetID",
      "OtherData"
   ),
   "EmpID",
   CountRows(OtherData)
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

@WarrenBelz Thank you for the reply 

but i get this error message

" Expected Text Value"

HI @SaeedKamel ,

Where did you put that code - as the Items of a Gallery, it will show the number of unique records with the combination of THDepartment and THBudgetID. and is valid code for this (I also just tested it here).

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

@WarrenBelz I am trying to add the code in the Spent Filed to calculate the unique values

@SaeedKamel ,

The code I gave you is for the Items of your Gallery and should produce (with the field names you requested) the results you displayed as required.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Helpful resources

Announcements
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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,252)