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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
v-zhouwen-msft
Community Support
Community Support

Hi @mh2587 ,thanks for the quick reply.

Hi @ChubbChubb ,

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

@v-zhouwen-msft it should work now to download the file.

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

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

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

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



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 ?

 


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.