Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
shansenTrek
Frequent Visitor

Referencing column with a Ranx

Hi Datanauts,

 

I am trying to create one table that will show the top performing employees for multiple periods of time like the table below.  It needs to be one table to be able to scroll and see all 50+ locations.

 

LocationEmployeeYesterday % of TotalEmployeePrior Day % of TotalEmployeeMonth % of Total
Store 1Steve47%Josh49%Steve48%
Store 2Royce60%Matt42%Erik54%
Store 3Thomas88%Thomas86%Thomas86%
Store 4George71%Wyatt42%George81%
Store 5Paul47%Paul48%Paul53%

 

My data table is structured as follows.  

 

DateYearLocationEmployeeAmount
5/13/20202020Store 1Steve447
5/13/20202020Store 2Royce281
5/13/20202020Store 3Thomas277
5/13/20202020Store 4George445
5/13/20202020Store 5Paul303
5/14/20202020Store 1Josh242
5/14/20202020Store 2Matt493
5/14/20202020Store 4Wyatt258
5/14/20202020Store 2Erik474

 

I have multiple measures to calculate the % of Total for the different time periods and then using the Rankx to rank employees by store for each time period.  But I cannot figure out the next steps to turn it into the desired table shown above.  Here is what my current table looks like.  

 

LocationYesterday RankYesterday % of TotalPrior Day RankPrior Day % of TotalMonth RankMonth % of Total
Store 1239%149%321%
Store 1147%225%148%
Store 1314%326%231%
Store 2160%318%225%
Store 2320%142%321%
Store 2220%240%154%
Store 3188%186%186%
Store 328%35%28%
Store 334%29%36%

 

Is there a way to reference the employee name associated with the rankings to replace the time period rankings with the employee?

 

Thanks!

2 ACCEPTED SOLUTIONS
v-zhenbw-msft
Community Support
Community Support

Hi @shansenTrek ,

 

We can use the following steps to meet your requirement.

 

1. Create a month column.

 

 

Month = MONTH('Table'[Date])

 

 

R 1.jpg

 

2. We can create six measures and put them to a table visual.

 

 

Yesterday E = 
var t = SUMMARIZE(FILTER('Table','Table'[Date] = TODAY()-1),'Table'[Employee],"YesterSales",SUM('Table'[Amount]))
return MAXX(TOPN(1,t,[YesterSales],DESC),[Employee])

 

 

 

Prior E = 
var t = SUMMARIZE(FILTER('Table','Table'[Date] = TODAY()-2),'Table'[Employee],"PSales",SUM('Table'[Amount]))
return MAXX(TOPN(1,t,[PSales],DESC),[Employee])

 

 

 

Month E = 
var t = SUMMARIZE(FILTER('Table','Table'[Month] = MONTH(TODAY())),'Table'[Employee],"MSales",SUM('Table'[Amount]))
return MAXX(TOPN(1,t,[MSales],DESC),[Employee])

 

 

 

Yesterday % of Total = 
var Y = TODAY()-1
return
CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Date]=Y)) / CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Date]=Y))

 

 

 

Prior Day % of Total = 
var Y = TODAY()-2
return
CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Date]=Y)) / CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Date]=Y))

 

 

 

Month % of total = 
DIVIDE(CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Month]=MONTH(TODAY()))) , CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Month]=MONTH(TODAY()))))

 

 

The result like this,

 

R 2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.       

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @shansenTrek ,

 

We can create three measures to replace [Yesterday % of Total], [Prior Day % of Total], [Month % of total].

 

Replace Yesterday % of Total = 
var x = [Yesterday E]
var y = MAX('Table'[Date])-1
return
CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Employee]=x && 'Table'[Date]=y)) / CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Date]=y))

 

Replace Prior Day % of Total = 
var x = [Prior E]
var y = MAX('Table'[Date])-2
return
CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Employee]=x && 'Table'[Date]=y)) / CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Date]=y))

 

Replace Month % of total = 
var x = [Month E]
var y = MONTH(MAX('Table'[Date]))
return
CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Employee]=x && 'Table'[Month] = y)) / CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Month]=y))

 

The result like this,

 

R 1.jpg

 

You also can replace MAX(Table[date]) to TODAY().

 

If it doesn’t meet your requirement, could you please provide a mockup sample  based on fake data?

 

It will be helpful if you can show us the exact expected result based on the tables. Please upload your files to OneDrive For Business and share the link here.

 

Please don't contain any Confidential Information or Real data in your reply.

 

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-zhenbw-msft
Community Support
Community Support

Hi @shansenTrek ,

 

We can use the following steps to meet your requirement.

 

1. Create a month column.

 

 

Month = MONTH('Table'[Date])

 

 

R 1.jpg

 

2. We can create six measures and put them to a table visual.

 

 

Yesterday E = 
var t = SUMMARIZE(FILTER('Table','Table'[Date] = TODAY()-1),'Table'[Employee],"YesterSales",SUM('Table'[Amount]))
return MAXX(TOPN(1,t,[YesterSales],DESC),[Employee])

 

 

 

Prior E = 
var t = SUMMARIZE(FILTER('Table','Table'[Date] = TODAY()-2),'Table'[Employee],"PSales",SUM('Table'[Amount]))
return MAXX(TOPN(1,t,[PSales],DESC),[Employee])

 

 

 

Month E = 
var t = SUMMARIZE(FILTER('Table','Table'[Month] = MONTH(TODAY())),'Table'[Employee],"MSales",SUM('Table'[Amount]))
return MAXX(TOPN(1,t,[MSales],DESC),[Employee])

 

 

 

Yesterday % of Total = 
var Y = TODAY()-1
return
CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Date]=Y)) / CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Date]=Y))

 

 

 

Prior Day % of Total = 
var Y = TODAY()-2
return
CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Date]=Y)) / CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Date]=Y))

 

 

 

Month % of total = 
DIVIDE(CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Month]=MONTH(TODAY()))) , CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Month]=MONTH(TODAY()))))

 

 

The result like this,

 

R 2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.       

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-zhenbw-msft, thank you so much for your help.  The Employee measures work great! Can you please help me tweak the % of total measures?  I want to display the % of the store total instead of the time period total.  The data I provided is not great and I apologize for that but the results for store 2 should look like this and everything else should be 100%.

 

LocationYesterday EYesterday %Prior EPrior %Month EMonth %
Store 2Matt51.0%Royce100%Matt40%

 

I tried to change the FILTER(ALL to the employee column but now there is an error saying it is looking for a single value.  I have tried multiple variations but to no avail.  Please help again!

Hi @shansenTrek ,

 

We can create three measures to replace [Yesterday % of Total], [Prior Day % of Total], [Month % of total].

 

Replace Yesterday % of Total = 
var x = [Yesterday E]
var y = MAX('Table'[Date])-1
return
CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Employee]=x && 'Table'[Date]=y)) / CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Date]=y))

 

Replace Prior Day % of Total = 
var x = [Prior E]
var y = MAX('Table'[Date])-2
return
CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Employee]=x && 'Table'[Date]=y)) / CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Date]=y))

 

Replace Month % of total = 
var x = [Month E]
var y = MONTH(MAX('Table'[Date]))
return
CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Employee]=x && 'Table'[Month] = y)) / CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Month]=y))

 

The result like this,

 

R 1.jpg

 

You also can replace MAX(Table[date]) to TODAY().

 

If it doesn’t meet your requirement, could you please provide a mockup sample  based on fake data?

 

It will be helpful if you can show us the exact expected result based on the tables. Please upload your files to OneDrive For Business and share the link here.

 

Please don't contain any Confidential Information or Real data in your reply.

 

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.