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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ivasgal
New Member

Weekly Calculation Based on Date Filter

Hello Experts,

 

I am new to Power BI and I'm struggling on creating a measurement that calculates how many inspections were done in the week based on what date the user selects in a slicer. 

 

I have 2 tables:

- DataDump Table (where all my entries are)
- Date Week Table (calendar table)

 

I have a slicer which shows dates from my Date Week Table, the user selects what day they want to see data from, then my visuals pull the data from my DataDump table for that day.

 

What I need is a measure that calculates how many inspections were or have been done in that week of the day selected. 

For example if user selects 01/05/2022, I want a measure that shows inspections done from 01/03/2022-01/09/2022

 

DataDump Table

ivasgal_0-1644599955177.png

 

Date Week Table

ivasgal_1-1644599994932.png

 

Date Slicer

ivasgal_3-1644600111757.png

 

I have this other calculation where it shows how many inspection done in the date range selected by user. On 01/05/2022 a total of 354 inspections were done

ivasgal_5-1644600268364.png

 

This is the formula I have for the measure above

ivasgal_6-1644600338449.png

 

Here is where I want to show the result. For this selection the result should be: 1607 inspections done for the week of 01/03/22-01/09/22

ivasgal_4-1644600130396.png

 

I just can't figure out how to do the formula to do what I need it to do. Hopefully I explained myself.

 

I appreciate the help!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ivasgal ,

 

Make sure the relationship between DataDump Table and Date Week Table is inactive.

You have weeknumber in the date week table so you could create a measure as below:

measure = calculate(counta(DataDump[rows]),filter(allselected(DataDump),weeknum(DataDump[inspections date],2) = selectedvalue(Date Week[week])))

 

Best Regards,

Jay

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @ivasgal ,

 

Make sure the relationship between DataDump Table and Date Week Table is inactive.

You have weeknumber in the date week table so you could create a measure as below:

measure = calculate(counta(DataDump[rows]),filter(allselected(DataDump),weeknum(DataDump[inspections date],2) = selectedvalue(Date Week[week])))

 

Best Regards,

Jay

amitchandak
Super User
Super User

@ivasgal , Have week rank column in you date/week tbale

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

then try measures

This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors