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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Greg_Deckler
Super User
Super User

Interesting Problem with Attendance

Had an interesting attendance issue come up at my user group recently. Basically it centers around attendance. The goal is to present a table/matrix visualization that displays all Employees within a certain date range that did not attend Training.

 

The core tables are these:

 

Employees

Employee

Greg
Bill
Joe
David
Jimbo

 

Training

Employee Training Date

GregTraining 1Tuesday, September 19, 2017
BillTraining 1Tuesday, September 19, 2017
JoeTraining 1Tuesday, September 19, 2017
DavidTraining 1Tuesday, September 19, 2017
JimboTraining 1Tuesday, September 19, 2017
GregTraining 2Saturday, August 19, 2017
BillTraining 2Saturday, August 19, 2017
DavidTraining 2Saturday, August 19, 2017
GregTraining 3Wednesday, July 19, 2017
BillTraining 3Wednesday, July 19, 2017
JoeTraining 3Wednesday, July 19, 2017
DavidTraining 3Wednesday, July 19, 2017
   


Hours

Employee Week Hours

GregSunday, September 17, 20175
GregSunday, September 10, 20175
GregSunday, September 3, 20175
GregSunday, August 27, 20175
GregSunday, August 20, 20175
GregSunday, August 13, 20175
GregTuesday, August 8, 20175
GregTuesday, August 1, 20175
JoeSunday, September 17, 20175
JoeSunday, September 10, 20175
JoeSunday, September 3, 20175
JoeSunday, August 27, 20175
JoeSunday, August 20, 20175
JoeSunday, August 13, 20175
JoeTuesday, August 8, 20175
JoeTuesday, August 1, 20175

 

 

The relationships are:

 

Employees 1<>* Hours

Employess 1>* Training

 

To this, we added a disconnected table Attendance:

 

Attendance

Attendance

Attended
Not Attended

 

We then added the following measures:

 

NotAttended = IF(ISBLANK(CALCULATE(MAX([Date]))),"Not Attended",BLANK())

Attended = IF(ISBLANK(MAX([Date])),BLANK(),"Attended")

Measures to Show = 
IF(
     HASONEVALUE(Attendance[Attendance]),
     SWITCH(
          VALUES(Attendance[Attendance]),
          "Attended",[Attended],
          "Not Attended",[NotAttended]
	 ),
	 MAX([Date])
)

We then created a matrix visualization:

  • Rows: Employees[Employee]
  • Columns: Training[Training]
  • Values: [Measures to Show]

And three slicers:

  • List slicer for Training[Training]
  • List slicer for Attendance[Attendance]
  • Date range slicer for Hours[Week]

So, everything works perfectly except when dealing with putting in a range for the date range slicer as well as clicking on "Not Attended" for the Attendance slicer. What occurs is that all of the people that are filtered out by the date range slicer suddenly pop back into the matrix with all "Not Attended" values.

 

I sort of get maybe what is going on but I can't for the life of me figure out exactly why quite honestly or how to fix it. For whatever reason, each individual is having the attendance measures calculated for them, which returns a value even though they should be already filtered out by the matrix visualization. 

 

If anyone out there can recreate this and tell me what is going on and better yet how to fix it, that would be really cool. Or, if you have an alternative solution that would provide the answer, that would be great. To be specific, if you filter the date range slicer at all and choose "Not Attended", then the only person in the matrix should be "Joe", not Bill, David and Jimbo as well.

 

 

 

 

 

 

 

 

 

 

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

OK, I may have solved this, I think changing the Measures to Show measure to this fixes it:

 

Measures to Show = 
IF(
     HASONEVALUE(Employees[Employee]),
     SWITCH(
          VALUES(Attendance[Attendance]),
          "Attended",[Attended],
          "Not Attended",[NotAttended]
	 ),
	 MAX([Date])
)

It seems that this forces it to honor the matrix context from what I can tell.

 

I would still REALLY love to know what is going on with the other way though. Is it because Employee is in the matrix, then it honors the context of the matrix but since Attendance is not explicitly in the matrix, it does not honor the matrix context??



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

OK, I may have solved this, I think changing the Measures to Show measure to this fixes it:

 

Measures to Show = 
IF(
     HASONEVALUE(Employees[Employee]),
     SWITCH(
          VALUES(Attendance[Attendance]),
          "Attended",[Attended],
          "Not Attended",[NotAttended]
	 ),
	 MAX([Date])
)

It seems that this forces it to honor the matrix context from what I can tell.

 

I would still REALLY love to know what is going on with the other way though. Is it because Employee is in the matrix, then it honors the context of the matrix but since Attendance is not explicitly in the matrix, it does not honor the matrix context??



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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