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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
RavirajMSE
Frequent Visitor

How to segregate slicer based on different column for one day before the selected date.

Suppose I have three Columns of a school attance sheet, I want To make slicer which will represent todays absent students based on date filter or by default today.

Now If want to add one more slicer which segregate the students who are absent today in two sections .

First Section

in the first section it should represent those students who were also absenty yesterday out of today's absenteesm,

and in section it will show the students from today's absent who were not absent yesterday,.

 

please help me out.

 

 

DateStudentAttandance
22-11-2022JohnAbsent
22-11-2022Ram'Present
22-11-2022RakPresent
22-11-2022TutuAbsent
22-11-2022RaviAbsent
22-11-2022Teja'Absent
22-11-2022VisheshPresent
21-11-2022JohnPresent
21-11-2022Ram'Absent
21-11-2022RakPresent
21-11-2022TutuAbsent
21-11-2022RaviPresent
21-11-2022Teja'Present
21-11-2022VisheshAbsent
21-11-2022JohnAbsent
20-11-2022Ram'Present
20-11-2022RakPresent
20-11-2022TutuAbsent
20-11-2022RaviAbsent
20-11-2022Teja'Absent
20-11-2022VisheshAbsent

 

Thanks & Regards

Raviraj Kumar Gupta

Business Analyst 

Pangeatech

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

Hi @RavirajMSE ,

 

According to your description, I made the sample and here is my solution. Please follow these steps.

Create a measure to return "Today Absent".

 

Today Absent =
VAR _slice =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _last =
    SELECTEDVALUE ( 'Table'[Date] ) - 1
RETURN
    CALCULATE (
        MAX ( 'Table'[Student] ),
        FILTER ( 'Table', 'Table'[Date] = _slice && 'Table'[Attandance] = "Absent" )
    )

 

Create a column to return the minimum of the DATE.

 

min date =
MIN ( 'Table'[Date] )

 

Create a measure to return the "Yesterday Absent".

 

Yesterday Absent =
VAR _slice =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _last =
    IF ( _slice > MAX ( 'Table'[min date] ), _slice - 1 )
RETURN
    CALCULATE (
        MAX ( 'Table'[Student] ),
        FILTER (
            ALL ( 'Table'[Date], 'Table'[Attandance] ),
            'Table'[Date] = _last
                && 'Table'[Attandance] = "Absent"
        )
    )

 

Create a measure to return the "Yesterday Present".

 

Yesterday Present =
VAR _slice =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _last =
    IF ( _slice > MAX ( 'Table'[min date] ), _slice - 1 )
RETURN
    CALCULATE (
        MAX ( 'Table'[Student] ),
        FILTER (
            ALL ( 'Table'[Date], 'Table'[Attandance] ),
            'Table'[Date] = _last
                && 'Table'[Attandance] = "Present"
        )
    )

 

Then put "Student", "Today Absent", "Yesterday Absent" into a table and select "is not blank" in the filter pane.

And put "Student", "Today Absent", "Yesterday Present" into another table and select "is not blank" in the filter pane.

You will get the expected output:

vxiaosunmsft_0-1669627520555.png

 

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ xiaosun

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

5 REPLIES 5
v-xiaosun-msft
Community Support
Community Support

Hi @RavirajMSE ,

 

According to your description, I made the sample and here is my solution. Please follow these steps.

Create a measure to return "Today Absent".

 

Today Absent =
VAR _slice =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _last =
    SELECTEDVALUE ( 'Table'[Date] ) - 1
RETURN
    CALCULATE (
        MAX ( 'Table'[Student] ),
        FILTER ( 'Table', 'Table'[Date] = _slice && 'Table'[Attandance] = "Absent" )
    )

 

Create a column to return the minimum of the DATE.

 

min date =
MIN ( 'Table'[Date] )

 

Create a measure to return the "Yesterday Absent".

 

Yesterday Absent =
VAR _slice =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _last =
    IF ( _slice > MAX ( 'Table'[min date] ), _slice - 1 )
RETURN
    CALCULATE (
        MAX ( 'Table'[Student] ),
        FILTER (
            ALL ( 'Table'[Date], 'Table'[Attandance] ),
            'Table'[Date] = _last
                && 'Table'[Attandance] = "Absent"
        )
    )

 

Create a measure to return the "Yesterday Present".

 

Yesterday Present =
VAR _slice =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _last =
    IF ( _slice > MAX ( 'Table'[min date] ), _slice - 1 )
RETURN
    CALCULATE (
        MAX ( 'Table'[Student] ),
        FILTER (
            ALL ( 'Table'[Date], 'Table'[Attandance] ),
            'Table'[Date] = _last
                && 'Table'[Attandance] = "Present"
        )
    )

 

Then put "Student", "Today Absent", "Yesterday Absent" into a table and select "is not blank" in the filter pane.

And put "Student", "Today Absent", "Yesterday Present" into another table and select "is not blank" in the filter pane.

You will get the expected output:

vxiaosunmsft_0-1669627520555.png

 

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ xiaosun

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

RavirajMSE
Frequent Visitor

Hey,

Thanks for your Suggestion, But it will return the count of those present and absent students, But I need the name of those students,

 

amitchandak
Super User
Super User

@RavirajMSE ,

Today Absent = CALCULATE(count('Table'[Student]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])), filter(Table, Table[Attandance] = "Absent") )

 

yesterday Absent = CALCULATE(count('Table'[Student]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1 ), filter(Table, Table[Attandance] = "Absent") )

 

Absent both days  = countx(filter(Values(Table[Student]), not(isblank([yesterday Absent])) && not(isblank([Today Absent])) ) , [Student])

 

Absent yesterday Present today = countx(filter(Values(Table[Student]), not(isblank([yesterday Absent])) && (isblank([Today Absent])) ) , [Student])


To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak 

Hey,

Thanks for your Suggestion, But it will return the count of those present and absent students, But I need the name of those students,

@RavirajMSE , Plot this measure with student's name in a visual. In a visual use this measure with student name

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.