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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

DAX Help with Date Question

Hello All,

I am trying to write a DAX code in Power BI but i keep getting an error. Could you help me with this.

 

Table 1.

Sales Date , Sales ID, Product category are columns

 

Table 2

Calendar table. (created by calendarauto() ). I have divided rows in this table into week start date. (For e.g. June 6th 2021 - June 13th 2021) = June 6th Start Date. 

 

What would be the DAX code to count the number of Sales during the week that started on June 6th, within a certain Product category. 

 

Thank you All

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Assume that the field 'Table 1'[Product category] be apply on the slicer, you can create a measure as below:

Measure =
CALCULATE (
    COUNT ( 'Table 1'[Sales ID] ),
    FILTER (
        'Table 1',
        'Table 1'[Product category] = SELECTEDVALUE ( 'Table 1'[Product category] )
            && WEEKNUM ( 'Table 1'[Sales Date] ) = WEEKNUM ( DATE ( 2021, 6, 6 ) )
    )
)

If the above one is not working for your scenario, please provide some sample data in Table 1 &Table 2(exclude sensitive data) and your expected result with specific examples and calculation logic. Thank you.

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

Assume that the field 'Table 1'[Product category] be apply on the slicer, you can create a measure as below:

Measure =
CALCULATE (
    COUNT ( 'Table 1'[Sales ID] ),
    FILTER (
        'Table 1',
        'Table 1'[Product category] = SELECTEDVALUE ( 'Table 1'[Product category] )
            && WEEKNUM ( 'Table 1'[Sales Date] ) = WEEKNUM ( DATE ( 2021, 6, 6 ) )
    )
)

If the above one is not working for your scenario, please provide some sample data in Table 1 &Table 2(exclude sensitive data) and your expected result with specific examples and calculation logic. Thank you.

Best Regards

Ashish_Mathur
Super User
Super User

Hi,

To your slicer, drag Week start date from the Calendar Table and select June 6, 2021 in that slicer.  Write these measures

Total = sum(data[sales])

Weekly total = calculate([total],datesbetween(calendar[date],min(calendar[date]),min(calendar[date])+6))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.