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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
samoberoi
Helper III
Helper III

Same card access timings on different dates

Hi

 

I have got the data where i needed to take the Min(First Access card scan) and Max(Last Access card scan) for each date for each employee and i needed to count that 4 different sites and in total, so i put the distinct count on Min and Max. However, when i put the filter on it and choose an employee who e.g. would have come on 21st Dec and scanned the card on entry at 8.30 AM and would have left and scanned out at 5.30 PM and on the next day on 22nd Dec would have scanned in the access card again at 8.30 AM and would have scanned out the card at 5.31, it gives me MIN only once because the time is same 8.30 for both dates and gives me Max correctly since the timings are different for exit.  The formulas i used are as following:

 

For calculating MIN ---  

Min = CALCULATE(
        MIN(Table(Time column),
        FILTER(ALLEXCEPT(Table,
        Table[Date column],
        Table[Card Number],Table[Sites column]),
        Table[In/Out column] = "IN"))
 
For Max --- 
Max = CALCULATE(
        MAX(Table(Time column),
        FILTER(ALLEXCEPT(Table,
        Table[Date column],
        Table[Card Number],Table[Sites column]),
        Table[In/Out column] = "OUT"))
 
Then to calculate the count of these MIN & MAX i used ;
SUMX(VALUES(Table[Card Number] )  ,CALCULATE(distinctCOUNT(Table[Min] )))
SUMX(VALUES(Table[Card Number] )  ,CALCULATE(distinctCOUNT(Table[Max] )))
 
So, how can i overcome this issue where it gives only one count for the same scan timing for two or more dates because distinctcount is applied and it should, instead, give me the distinct count for each day.

Hope i could be able to explain it better.
 
WIll be thankful for the help.
 
Regards
1 ACCEPTED SOLUTION
sturlaws
Resident Rockstar
Resident Rockstar

Hi, @samoberoi,

 

if a card is scanned on multiple sites on a date, it should count as 1? Assuming this is the case, you can write your measures like this:

MeasureNumberOf_IN =
VAR _tmp =
    SUMMARIZE (
        CALCULATETABLE ( 'Table', 'Table'[In/Out] = "In" ),
        'Table'[Card_id],
        'Table'[Date]
    )
RETURN
    COUNTROWS ( _tmp )

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

 

How to Get Your Question Answered Quickly

View solution in original post

2 REPLIES 2
sturlaws
Resident Rockstar
Resident Rockstar

Hi, @samoberoi,

 

if a card is scanned on multiple sites on a date, it should count as 1? Assuming this is the case, you can write your measures like this:

MeasureNumberOf_IN =
VAR _tmp =
    SUMMARIZE (
        CALCULATETABLE ( 'Table', 'Table'[In/Out] = "In" ),
        'Table'[Card_id],
        'Table'[Date]
    )
RETURN
    COUNTROWS ( _tmp )

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

 

How to Get Your Question Answered Quickly

HI Sturlaws,

Boom! It worked great. I may not have words to express the level of thankfulness to you for your help; however, i am thankful to you a million times. I was stuck on this for days. 
Thanks again & regards

Sam

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.