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
jordanxie
Helper I
Helper I

Consecutive Weeks for Material

Hi,

 

Want to create a measure to be used as a card view that counts the consecutive weeks a material is present. The format for the date is Yr-Wk# (2019-46). 

 

Let's say we are in Wk 48 so the card should display count for Material 1 as 2 (2019-47 & 2019-48), Material 2 as 1 (becuase it is not present in 2019-47 even though it appeared in 2019-45 & 2019-46)

 

Material         Yr-Wk#

1                    2019-45

2                    2019-45

2                    2019-46

1                    2019-47

1                    2019-48

2                    2019-48

 

Any help is appreciated. Thanks in advance

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @jordanxie ,

 

You could use the following measure:

Measure =
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        'Table',
        VALUE ( RIGHT ( 'Table'[Yr-Wk#], 2 ) )
            IN { WEEKNUM ( TODAY (), 1 ), WEEKNUM ( TODAY (), 1 ) - 1 }
    )
)

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

3 REPLIES 3
v-eachen-msft
Community Support
Community Support

Hi @jordanxie ,

 

You could use the following measure:

Measure =
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        'Table',
        VALUE ( RIGHT ( 'Table'[Yr-Wk#], 2 ) )
            IN { WEEKNUM ( TODAY (), 1 ), WEEKNUM ( TODAY (), 1 ) - 1 }
    )
)

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
TomMartens
Super User
Super User

Hey,

 

can you please describe the business rule more detailed, I have difficulties to understand why material 2 get a 1 even if there are 2 two consecutive events in the past.

 

Assuming that the week is selected by a slicer.

 

What would be the value for material 2 is there is a value for week 2019-47?

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi,

 

At this point we are more concern based on the latest snapshot (Week 48). There would not be a slicer for the week. 

 

If there was a a material 2 for 2019-47, then the count would be 4

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!

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 Solution Authors
Top Kudoed Authors