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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
ChubbChubb
Helper I
Helper I

Attendance type over 10 Weeks

I need to work out on a rolling 10 week block how many particular attendance codes students have recieved during that 10 week cycle and if it is 10 or more flag them.

 

This is the code I use to work out the attendance type %

 

Unauthorised = CALCULATE(
        COUNTROWS(ROLL_CALL_ATTENDANCE),
            FILTER(ROLL_CALL_ATTENDANCE,ROLL_CALL_ATTENDANCE[IS_UNAUTHORIZED_ABSENT]=TRUE()),
            FILTER(ROLL_CALL_ATTENDANCE,ROLL_CALL_ATTENDANCE[IS_POSSIBLE_ATTENDANCE]=TRUE())
          )
 
My thoughts are to do a formula that looks up todays date and gets the WEEK INDEX from the date table and then work back 9 weeks to get a start date add it as a filter, and then if it counts more than 10 in that time flag them True/False
 
not sure if I am on the right track with that?
 
All help appreciated.
12 REPLIES 12
Anonymous
Not applicable

Hi @mh2587 ,thanks for the quick reply.

Hi @ChubbChubb ,

I can't seem to open the link you shared.

@Anonymous it should work now to download the file.

Anonymous
Not applicable

Hi @ChubbChubb ,

Are there other ways you can share your files?

I'm not sure to be honest, Its a shame I cna't just upload a file to the forum

Anonymous
Not applicable

Hi @ChubbChubb ,

You can upload pbix files to OneDrive, Google Drive and share the links.

that's what I did with the link here it is again example data.pbix

Anonymous
Not applicable

Hi @ChubbChubb ,

Please follow these steps:

1. Use the following DAX expression to create a column in 'DATE_TABLE'(If today is not within a semester, find the nearest future date within a semester)

 

Column = IF(ISBLANK([Term Week Index]),MINX(FILTER('DATE_TABLE',[Date] >= EARLIER([Date]) && [Term Week Index] <> BLANK()),[Date]))

 

vzhouwenmsft_0-1714641775618.png

2.Use the following DAX expression to create a table named 'Table'

 

Table = FILTER('DATE_TABLE','DATE_TABLE'[Term Week Index] <> BLANK())

 

3.Use the following DAX expression to create a column in 'Table'

 

Column 2 = COUNTROWS(FILTER('Table',[Date] <= EARLIER('Table'[Date])))

 

vzhouwenmsft_1-1714643495480.png

4.Use the following DAX expression to create a measure(I assumed the date.)

 

Measure = 
VAR _today = DATE(2021,12,16)
VAR isTearmDay = LOOKUPVALUE('DATE_TABLE'[Term Week Index],DATE_TABLE[Date],_today)
VAR _a = LOOKUPVALUE(DATE_TABLE[Column],'DATE_TABLE'[Date],_today)
VAR startDay = IF(ISBLANK(isTearmDay),_a,_today)
VAR _b = LOOKUPVALUE('Table'[Column 2],'Table'[Date],startDay) + 69
VAR endDay = LOOKUPVALUE('Table'[Date],'Table'[Column 2],_b)
VAR _c = SELECTCOLUMNS(FILTER('Table','Table'[Date] >= startDay && 'Table'[Date] <= endDay),"Date",[Date])

VAR _d = CALCULATE(
        COUNTROWS(ROLL_CALL_ATTENDANCE),
            FILTER(ROLL_CALL_ATTENDANCE,ROLL_CALL_ATTENDANCE[IS_UNAUTHORIZED_ABSENT]=TRUE()),
            FILTER(ROLL_CALL_ATTENDANCE,ROLL_CALL_ATTENDANCE[IS_POSSIBLE_ATTENDANCE]=TRUE()),
            FILTER(ROLL_CALL_ATTENDANCE,ROLL_CALL_ATTENDANCE[DATE] IN _c)
          )

RETURN _d

 

 

ChubbChubb
Helper I
Helper I

mh2587
Super User
Super User

Rolling_10Week_Attendance_Flag = //Try this one
VAR StartDate = TODAY() - 63  // 63 days = 9 weeks
VAR EndDate = TODAY() // Current date
RETURN
    CALCULATE(
        COUNTROWS(ROLL_CALL_ATTENDANCE),
        FILTER(
            ROLL_CALL_ATTENDANCE,
            ROLL_CALL_ATTENDANCE[AttendanceDate] >= StartDate &&
            ROLL_CALL_ATTENDANCE[AttendanceDate] <= EndDate
        )
    ) >= 10

✔ Answered? Mark as solution

Muhammad Hasnain | Super User • Fabric • Power BI • Data Engineering

Let's connect on LinkedIn

thanks, I have to take into account school holidays, which is where the WEEK INDEX comes in as my date table contains all dates and I'm using the WEEK INDEX to show which are term dates.

Can you please share sample data ?

 


✔ Answered? Mark as solution

Muhammad Hasnain | Super User • Fabric • Power BI • Data Engineering

Let's connect on LinkedIn

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.