How to get the Max unique value for a particular person from two different columns

Mavericks334

Active Member
Joined
Jan 26, 2011
Messages
280
Hi,

I have 3 columns { Preparer Name, REviewer NAme, Completed Date}
I need to get the max no of days where person has worked, by counting unique dates from completed date.

i am able to get the unique dates by using COuntsrows(Distinct(Completed date)).

However i need to get the max days where the person has worked, the person could either be in preparer or reviewer or in both.

REgards,
Renato.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
hi, Renato. In normal Excel, I don't have Power Pivot, try below. Untested. HTH
Code:
SELECT Name, COUNT(*)
FROM
(SELECT DISTINCT Name, INT(Completed Date)
FROM
(
SELECT [Preparer Name] AS [Name], [Completed Date]
FROM table
UNION
SELECT [Reveiwer Name] AS [Name], [Completed Date}
FROM table))
GROUP BY Name
 
Upvote 0
Sorry, Renato. I have some typos & can't edit them. Browser keeps crashing. Please use the following instead, there were errors previously.

Code:
SELECT Name, COUNT(*)
FROM
(SELECT DISTINCT Name, INT(Completed Date)
FROM
(
SELECT [Preparer Name] AS [Name], [Completed Date]
FROM table
UNION
SELECT [Reviewer Name] AS [Name], [Completed Date]
FROM table))
GROUP BY Name
 
Upvote 0
Hi Fazza,

Thanks for the help.

If you could provide me the solution for power pivot would be great.

I am currently using =CALCULATE(COUNTROWS(DISTINCT('SharePoint Data'[Uniquedate])),ALL('SharePoint Data'[Preparer]))
To get the unique values for the preparer, however when i try and use reviewer at the end, it still calculates the values for preparer, i dont know why.


 
Upvote 0
Hi Fazza,

Thanks for the help.

If you could provide me the solution for power pivot would be great.

I am currently using =CALCULATE(COUNTROWS(DISTINCT('SharePoint Data'[Uniquedate])),ALL('SharePoint Data'[Preparer]))
To get the unique values for the preparer, however when i try and use reviewer at the end, it still calculates the values for preparer, i dont know why.



To get the data for reviewers, you will have to use the inactive relationship (with USERELATIONSHIP).

In your case, you will have to use a FILTER expression on your 'Sharepoint Data' table, with a condition using both your active relationship and your inactive relationship.
 
Upvote 0
To get the data for reviewers, you will have to use the inactive relationship (with USERELATIONSHIP).

In your case, you will have to use a FILTER expression on your 'Sharepoint Data' table, with a condition using both your active relationship and your inactive relationship.

Hi Laurent,

I tried the below expression and it did not work,

=(COUNTROWS(DISTINCT('SharePoint Data'[Uniquedate])),USERELATIONSHIP('SharePoint Data'[Reviewer]))

Could you let me know, what changes i need to make.
 
Upvote 0
=CALCULATE(COUNTROWS(DISTINCT('SharePoint Data'[Uniquedate])),USERELATIONSHIP('SharePoint Data'[Reviewer],'Employee Details'[Employee Name]),'SharePoint Data'[Recon Category]="Cash")

It worked
 
Upvote 0

Forum statistics

Threads
1,223,931
Messages
6,175,465
Members
452,645
Latest member
Tante

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top