cancel
Showing results for
Did you mean:
Highlighted
Regular Visitor

## Rank table over 3 different months

I have a table which contains employee utilisation over the course of the year - something like this:

 Employee Year Month Utilisation E1 2017 1 75% E1 2017 2 73% E1 2017 3 78% E1 2017 4 64% E1 2017 5 80% E1 2017 6 79% E2 2017 1 66% E2 2017 2 69% E2 2017 3 79% E2 2017 4 75% E2 2017 5 78% E2 2017 6 79% E3 2017 1 74% E3 2017 2 75% E3 2017 3 79% E3 2017 4 84% E3 2017 5 82% E3 2017 6 81%

I woud like to use two slicers to select year / month and then display three tables of results showing employees ranked by their utilisation in current, previous and previous-1 months.

So, if I select 2017 / 5 I want to see:

Current Period (2017/5)

1 E3 82%

2 E1 80%

3 E2 78%

Previous Period (2017/4)

1 E3 84%

2 E2 75%

3 E1 64%

Previous -1 Period (2017/3)

1 E3 79%

2 E2 79%

3 E1 78%

Average over Last 3 Periods

1 E3 81.66%

2 E2 77.33%

3 E1 74%

I thought I could just create a simple measure:

Rank = RANKX(ALLSELECTED(UTILISATION),CALCULATE(SUM(UTILISATION[Utilisation])))

And then filter each visual on a month / year basis but a) this is not very dynamic and I will need to manually select the month numbers for each period and b) I also found that the ranking for the average over the 3 periods all returned number 1. So I think I'm going about it the wrong way.

I need to:

1. determine from the slicer the year / month selected and then rank only the rows that match the same period

2. do the same for previous periods

3 average and rank over the 3 periods (i.e. return 1 row / result for each employee).

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

## Re: Rank table over 3 different months

@AndyTrezise,

This is a calculated column but not a measure, it calculates rank of utilisation of same year and same Month, which achieves your requirement.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 REPLIES 4
Moderator

## Re: Rank table over 3 different months

@AndyTrezise,

1.Create Year table containing year values(2016,2017…), create Month table containing month values(1,2,3…12). Please note that there is no relationship among the three tables(Year, Month and UTILISATION table).

2. Create the following calculated columns in the UTILISATION table.

`Date = DATE(UTILISATION[Year],UTILISATION[Month],1)`

`RankColumn = RANKX(FILTER(UTILISATION,UTILISATION[Year]=EARLIER(UTILISATION[Year])&&UTILISATION[Month]=EARLIER(UTILISATION[Month])),UTILISATION[Utilisation],,DESC,Dense)`

3. Create the following measures in UTILISATION table.

```checkmonth =
var Ldate = date(max('Year'[Year]),max('Month'[Month]),1) //Last date

var Fdate = EDATE(Ldate,-2) //First date

return

if(min('UTILISATION'[Date])<fdate,
blank(),
if(min('UTILISATION'[Date])>Ldate,
blank(),
1))
```

```Average =
var Ldate = date(max('Year'[Year]),max('Month'[Month]),1) //Last date

var Fdate = EDATE(Ldate,-2) //First date

return

(CALCULATE(SUM(UTILISATION[Utilisation]),DATESBETWEEN(UTILISATION[Date],Fdate,Ldate)))/3
```

`Rank = RANKX(ALLSELECTED(UTILISATION[Employee]),[Average],,DESC,Dense)`

4. Create a table visual as follows, drag checkmonth  to visual level filters and set its value to 1. The second table visual doesn't require to set checkmonth.

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Regular Visitor

## Re: Rank table over 3 different months

Thank you very much for the reply and detailed explanation.

Most of it makes sense 🙂

I'm a little unsure what the 'RankColumn' measure means (i.e. I don't understand the logic - particularly the part highlighted) or how it is being used in the solution.

RankColumn = RANKX(FILTER(UTILISATION,UTILISATION[Year]=EARLIER(UTILISATION[Year])&&UTILISATION[Month]=EARLIER(UTILISATION[Month])),UTILISATION[Utilisation],,DESC,Dense).

Thanks

Moderator

## Re: Rank table over 3 different months

@AndyTrezise,

This is a calculated column but not a measure, it calculates rank of utilisation of same year and same Month, which achieves your requirement.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Regular Visitor

## Re: Rank table over 3 different months

Got it!

Thank you very much.

Announcements