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
samoberoi
Helper II
Helper II

Access into college twice a week

Hi, 

 

I previously have managed to get the Min and Max of all the students out from all the swipes of the access card done during the day at the entrance gate, which gave me the students' first entrance and last exit from the building and i did the full count of all the students' first entry and last exit during the week or day etc. This works fine till now. Now, i have to count how many students have been into the building just three days a week. Is there any form of DAX which will help me in extracting the students who have been in just three days a week? I am really struggling with it. 
Help will be much appreciated. 


Thanks

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

Hi @samoberoi ,

 

I think your Table should look like as below. You can add a [Date] column in your table.

vrzhoumsft_1-1696403154506.png

Date = IF(DATEVALUE('Table'[Entrance]) = DATEVALUE('Table'[Exit]),DATEVALUE('Table'[Entrance]))

I suggest you to create a Calendar table to help calculation.

Calendar = 
ADDCOLUMNS (
    CALENDAR ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ) ),
    "Year", YEAR ( [Date] ),
    "Month", MONTH ( [Date] ),
    "WeekDay", WEEKDAY ( [Date], 2 ),
    "WeekStart",
        [Date] - WEEKDAY ( [Date], 2 ) + 1,
    "WeekEnd",
        [Date] - WEEKDAY ( [Date], 2 ) + 7,
    "WeekRange",
        COMBINEVALUES (
            " - ",
            [Date] - WEEKDAY ( [Date], 2 ) + 1,
            [Date] - WEEKDAY ( [Date], 2 ) + 7
        )
)

Data model:

vrzhoumsft_0-1696403133513.png

Measure:

Count Students in buildings three days = 
VAR _SUMMARIZE = SUMMARIZE('Table','Table'[Student ID],'Calendar'[WeekRange],"Count",CALCULATE(DISTINCTCOUNT('Table'[Date])))
RETURN
COUNTX(FILTER(_SUMMARIZE,[Count]=3),[Student ID]) + 0

Result is as below.

vrzhoumsft_2-1696403227358.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
samoberoi
Helper II
Helper II

Hi

 

I can't thank you enough for this help. Stay blessed.

 

Cheers!

v-rzhou-msft
Community Support
Community Support

Hi @samoberoi ,

 

I think your Table should look like as below. You can add a [Date] column in your table.

vrzhoumsft_1-1696403154506.png

Date = IF(DATEVALUE('Table'[Entrance]) = DATEVALUE('Table'[Exit]),DATEVALUE('Table'[Entrance]))

I suggest you to create a Calendar table to help calculation.

Calendar = 
ADDCOLUMNS (
    CALENDAR ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ) ),
    "Year", YEAR ( [Date] ),
    "Month", MONTH ( [Date] ),
    "WeekDay", WEEKDAY ( [Date], 2 ),
    "WeekStart",
        [Date] - WEEKDAY ( [Date], 2 ) + 1,
    "WeekEnd",
        [Date] - WEEKDAY ( [Date], 2 ) + 7,
    "WeekRange",
        COMBINEVALUES (
            " - ",
            [Date] - WEEKDAY ( [Date], 2 ) + 1,
            [Date] - WEEKDAY ( [Date], 2 ) + 7
        )
)

Data model:

vrzhoumsft_0-1696403133513.png

Measure:

Count Students in buildings three days = 
VAR _SUMMARIZE = SUMMARIZE('Table','Table'[Student ID],'Calendar'[WeekRange],"Count",CALCULATE(DISTINCTCOUNT('Table'[Date])))
RETURN
COUNTX(FILTER(_SUMMARIZE,[Count]=3),[Student ID]) + 0

Result is as below.

vrzhoumsft_2-1696403227358.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.