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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Find Max Day per Week

Hello - I have a database where each time a punch is read it counted and put in as a row. Total for that day is the number of rows added (does have a date of punch column)

 

I want to find what day has the most punches for the week, how can this be done?

 

Using 

Punches = CALCULATE(COUNTROWS('Sum Log'),FILTER(ALL('Sum Log'),'Sum Log'[Week Ending Date]=MAX('Sum Log'[Week Ending Date]))
 
Gives the total for the week
1 ACCEPTED SOLUTION

Hi,

 

I think you have misunderstood my data, and the last day of each week only represents this week and the max value is not the end day's value.

So i add an column to the original table:

Week = SWITCH('Table'[WeekEnd],DATE(2020,2,8),"Week-1",DATE(2020,2,15),"Week-2",DATE(2020,2,22),"Week-3")

And i think you should already have the column like the above to represent each week.

The result shows:

82.PNG

Here is my test pbix file:

pbix 

 

Best Regards,

Giotto Zhi

View solution in original post

10 REPLIES 10
Greg_Deckler
Community Champion
Community Champion

So do you have something that tells you the day in the data? Sample data would assist greatly. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Greg - the data is set like this

 

Date       Punch    WeekEnd

2/1/20   B               2/8/20

2/1/20   B               2/8/20

2/1/20   B               2/8/20

2/1/20   B               2/8/20

2/2/20   B               2/8/20

2/2/20   B               2/8/20

Hi,

 

According to your description, i create a table to test:

31.PNG

Please try to create this measure:

Measure = 
var a = TOPN(1,SUMMARIZE('Table','Table'[Date],"Count",COUNTROWS('Table')),MAX([Count]),DESC)
var maxDate = MAXX(a,'Table'[Date])
return
DATE(YEAR(maxDate),MONTH(maxDate),DAY(maxDate))

Put this measure into Card visual, the result shows the max count of Punches forthe week:

32.PNG

Hope this helps.

 

Best Regards,

Giotto Zhi

Anonymous
Not applicable

Sorry, I explained this poorly.

 

I want to graph the highest value per work on a bar graph rather than displaying the date

Max Percentage measure =
VAR MaxYear =
    CALCULATE (
        MAX ( 'User Table'[Year] ),
        ALLEXCEPT ( 'User Table', 'User Table'[Category] )
    )
RETURN
    CALCULATE (
        MAX ( 'User Table'[Percentage] ),
        FILTER (
            ALLEXCEPT ( 'User Table', 'User Table'[Category] ),
            'User Table'[Year] = MaxYear
        )
    )

 I Tried this and it didn't work as intended - only displaying the saturday value

Hi,

 

I add some data to my original test file.

Please try this measure:

Measure = 
var a = TOPN(1,SUMMARIZE('Table','Table'[Date],"Count",COUNTROWS('Table')),MAX([Count]),DESC)
var maxDate = MAXX(a,'Table'[Date])
return
DAY(maxDate)

Then choose [WeekEnd] column and this measure, the result shows:

41.PNG

 

Best Regards,

Giotto Zhi

Anonymous
Not applicable

It's only getting the max value for the last day of the week. I'm looking to take the max per week, not just the max at the end of the week

Hi,

 

I think you have misunderstood my data, and the last day of each week only represents this week and the max value is not the end day's value.

So i add an column to the original table:

Week = SWITCH('Table'[WeekEnd],DATE(2020,2,8),"Week-1",DATE(2020,2,15),"Week-2",DATE(2020,2,22),"Week-3")

And i think you should already have the column like the above to represent each week.

The result shows:

82.PNG

Here is my test pbix file:

pbix 

 

Best Regards,

Giotto Zhi

Anonymous
Not applicable

I'm still not getting correct results

If you are looking for only max value per week, then rank can help.

rankx(all('User Table'[Week end date]),MAX ( 'User Table'[Percentage] ),,desc,dense)

How to filter on rank:https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...

 

If you need a max value on the max date of the week , that is a different context

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you, this worked great. 

How can I get the actual number rather than the date? thanks!

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

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.