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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.

 

 

 

 

 

 

 

 

 

 

 

 


@ 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!:
The Definitive Guide to Power Query (M)

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??


@ 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!:
The Definitive Guide to Power Query (M)

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??


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.