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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Dwivedi15
Helper I
Helper I

last week count not working properly

I have a date table which formulates all the dates for given field.

Dwivedi15_0-1687785537317.png



Now i have a field which says- task end date through which i calculate last week tasks- for some reason total tasks are coming exact but not exact when go for individual category.

Dwivedi15_1-1687785638104.png


In power BI its coming as : 

Dwivedi15_2-1687785696568.png

 


The last week tasks are counted using :

total tasks Last week =
Var CurrentWeek=Weeknum(today())
var CurrentYear=Year(today())
Var MaxWeekNumber=Calculate(max('Date'[Week Number]),all('Date'))
return
sumx(filter(all('Date'),if(CurrentWeek=1,'Date'[Week Number]=MaxWeekNumber && 'Date'[Year]=CurrentYear-1,
'Date'[Week Number]=CurrentWeek-1 && 'Date'[Year]=CurrentYear)),[Total Tasks_filtered])

Total Tasks_filtered =
CALCULATE(COUNTROWS('Task Volumes'),'Task Volumes'[Project Ref]<>"TOOLING_CHECK" && 'Task Volumes'[Project Ref]<>"VAN_PLANT" && 'Task Volumes'[Management Area]<>"T.POPE")

This measure- Total_tasks_filterd is working perfect when counting all rows for last week :
Dwivedi15_3-1687785838709.pngDwivedi15_4-1687785981441.png



I am not sure why this is happening, i am not able to debug. Any help would be appreciated.

Many thanks!



 
12 REPLIES 12
Greg_Deckler
Community Champion
Community Champion

@Dwivedi15 In response to your private message. One thing I noticed immediately is that in your Date table, you only have 6 dates for last week (7/2/2023). Looks like you are missing Saturday the 8th. Perhaps this is causing some of your problem?



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...

Hi greg,

 

PBIX- https://drive.google.com/file/d/1faZg-lGf7mCdmayB3VfHwrg9-VeW1_Rn/view?usp=sharing

Excel - https://docs.google.com/spreadsheets/d/1ncfajPPnBrDKh9moN7N5Tco7EZYqeOv-/edit?usp=sharing&ouid=10989...

 

Excel for just last week: https://docs.google.com/spreadsheets/d/1E3NAOYTqcfqmQSDpNEYI-ykK3U8AsS0v/edit?usp=sharing&ouid=10989...

 

If you see here indiviual count of tasks are not coming correct but overall is coming right. Also total aborts works just fine.
REally cant understand why !!!?

Dwivedi15_0-1689156645372.png

 



lbendlin
Super User
Super User

Your MaxWeekNumber calculation needs to be corrected to calculate the proper max week of the prior year ( for current week =1 )

Can you please elaborate? i did not get you!

Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

how can i share my PBIX and Excel file ?

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Hi,

 

PBIX- https://drive.google.com/file/d/1faZg-lGf7mCdmayB3VfHwrg9-VeW1_Rn/view?usp=sharing

Excel - https://docs.google.com/spreadsheets/d/1ncfajPPnBrDKh9moN7N5Tco7EZYqeOv-/edit?usp=sharing&ouid=10989...

 

Excel for just last week: https://docs.google.com/spreadsheets/d/1E3NAOYTqcfqmQSDpNEYI-ykK3U8AsS0v/edit?usp=sharing&ouid=10989...

 

If you see here indiviual count of tasks are not coming correct but overall is coming right. Also total aborts works just fine.
REally cant understand why !!!?

Dwivedi15_1-1689156688187.png

 

 

Excel file for all data from 2021 Jan: https://docs.google.com/spreadsheets/d/160A5HKN1xuI-3UgQgFK0npHJuwRFX_qc/edit?usp=sharing&ouid=10989...

 

Excel file for just last week: 
https://drive.google.com/file/d/1xN6-74xf1tayMtgb9jJeS5zZ_B1byPAD/view?usp=sharing

 

 

PBIX file :
https://drive.google.com/file/d/1xN6-74xf1tayMtgb9jJeS5zZ_B1byPAD/view?usp=sharing

 

If you see, here last week count is not coming correct for individual 'Management Area' for both count of tasks and Aborts.

 

Kindly help me figure this out.

 

Many Thanks in advance!!

 

 

Dwivedi15
Helper I
Helper I

Hi , This week rank is not working out for me, now even the overall number is not coming correct!

amitchandak
Super User
Super User

@Dwivedi15 ,

Have these new columns in Date Table, Week Rank is Important in Date/Week Table

Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW format


These measures can help
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))

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8
Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510

 

 

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

Hi This does not work for me, as now even the total number of rows arent coming out correct!

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.