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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Nhphong
Regular Visitor

How to countrows with filter weeknum of yearnum

Hello,

I had trouble with dax function while trying to get data with 2 filters. There are This week and last week of year 2023.

Currently, i have dax function that can get data

Last week: Calculate(Countrows'Table'),Filter('Table',[Weeknum]=Max[weeknum] -1)

This week: Calculate(Countrows'Table'),Filter('Table',[Weeknum]=Max[weeknum])

Everything is fine until data passed to 2023, my Max[weeknum] isn't correct anymore because the Max[weeknum] is on 2022.

Tried dax function: Calculate(Countrows'Table'),Filter('Table',[Weeknum]=Max[weeknum] && [Year]=2023) but it returns blank value.

 

Thanks & Regards,

Hoai Phong

2 REPLIES 2
Ahmedx
Super User
Super User

You need to create a column in the calendar table
WEEK Order =DATEDIFF(TODAY(),[Date],WEEK))
 
further like this
This week = CALCULATE([Value sum],'Calendar'[WEEK Order]=0)
Last week = CALCULATE([Value sum],'Calendar'[WEEK Order]=-1)

Screen Capture #209.png

Hi,

Thank you for reply. But i still can't figure how to use DATEDIFF to solve my problem.

I want to countrows with 2 filters. There are 2023 in year column and maximum weeknum of 2023.

Nhphong_0-1673411147905.png

 

Thanks & Regards,

Hoai Phong

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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