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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Calculate Average Based on Category Count and Date

Hi,

 

I'm trying to build a graph like below :

 

asmita_sharma_0-1663643462667.png

 

 

where only the categories with maximum count (from bottom) or maximum count (from top) are considered while trying to graph it based on the average time taken to finish a task.

 

As there are like 100's of categories with 100's of counts (as it's a dataset worth this whole year) - it graph's with even if it's got one value (highest or lowest - in my case it will be an outlier if that makes sense). I'm trying to look for an average trend rather than individual result and hence looking for top 5 (shortest time) average/bottom 5 (longest time) average over a period of time (in this instance - every month/ but would also like every month too)

 

Any help with the dax query would help.

 

I would prefer not to create an additional summarize table as already have several tables linked in the backend.

 

I've attached a dummy data too.

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous As you see in your graph, there's one data point for pencil - that's what I do want to ignore and only average out the category which has a count of more than 5 - because when I do put the measure as stated above - it gives me all the results (including outliers - which means anything below than count of 5 as well)

Anonymous
Not applicable

Dummy Data:

DateCategoryTime (Mins)
20/01/2022Pen5
20/01/2022Paper10
20/01/2022Pencil15
20/01/2022Pen20
21/01/2022Pen1
22/01/2022Pen2
23/01/2022Paper0
24/01/2022Paper5
25/01/2022Paper10
26/01/2022Paper4
27/01/2022Paper2
28/01/2022Paper6
29/01/2022Paper7
29/01/2022Paper1
29/01/2022Paper7
29/01/2022Paper45
30/01/2022Paper2
31/01/2022Paper3
1/02/2022Paper25
2/02/2022Paper6
3/02/2022Paper66
4/02/2022Paper88
5/02/2022Pen100
6/02/2022Pen130
7/02/2022Pen150
7/02/2022Pen170
5/02/2022Pen190
4/02/2022Pen220
4/02/2022Pen235
7/02/2022Pen260
7/02/2022Pen200
7/02/2022Pen30
Anonymous
Not applicable

Hi @Anonymous ,

 

I suggest you to try this measure.

Measure = 
VAR _ADD = ADDCOLUMNS('Table',"YearMonth",YEAR([Date])*100+MONTH([Date]))
VAR _ADDRANK = ADDCOLUMNS(_ADD,"RANK1",RANKX(FILTER(_ADD,[YearMonth] = EARLIER([YearMonth]) && [Category] = EARLIER([Category])),[Time (Mins)],,DESC,Dense),
"RANK2",RANKX(FILTER(_ADD,[YearMonth] = EARLIER([YearMonth]) && [Category] = EARLIER([Category])),[Time (Mins)],,ASC,Dense))
RETURN
AVERAGEX(FILTER(_ADDRANK,[RANK1]<=5||[RANK2]<=5),[Time (Mins)])

Result is as below.

RicoZhou_0-1663751931642.png

 


Best Regards,
Rico Zhou

 

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

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors