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

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,924)