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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
deb_power123
Helper V
Helper V

Unable to add(sum) the flags set to 1 in PowerBI Matrix visualzation

Hi All,

 

I am facing an issue in PowerBI matrix visualization.I have a school table with column values Student_ID,Location and AttendanceDate.

 

I need to find the sum of the number of times each student who attended classes >=1 days per location per month.

 

I have created a custom measure named Attendance as stated below to calculate students who the attended classes >=1

 
 
Attendance = IF(DISTINCTCOUNT(school[Attendance_Date])>=1,1,0)
 
In my visualization, I am able to get all the flags which is set to '1' for all the students who meet the condtion of attending classes>=1.But as per my requirement  I want to get the sum of these 1 flags to get the number of times all students attended classes >=1 per location per month.My final visulization should not contain the student ID, it should only have the location and months and the sum of the flags set to 1 indicating the number of times students attended the classes >=1 .
 
Expected Output:-
 
Location    January   February March 
Chennai       1             1             1
Delhi            2              2             2
Goa              0              2             0
 
I tried to implement the fixed LOD concept as we do in tableau to handle this scenario in PowerBI but no luck.
 
I created a  calculated measure 'CalculateAttendance as below but it is not working :-
 
Calc ulateAttendance = CALCULATE((school[Attendance]),ALLEXCEPT(school[Student_ID],school[Location],school[Attendance]))
 
Could you please provide any changes to my above calculations to resolve this issue.Please help. I wanted to add .pbix file too but this post doesnt have an insert file option.I have added the data source excel and the present visualization screenshot as below.
 
Regards
Sameer
 
Current  Matrix Visualization screenshot:-
Student_visual.JPG
Input data source excel:
AttendanceStudentIDLocation
01.01.2017100Delhi
02.01.2017100Delhi
03.01.2017100Delhi
04.01.2017100Delhi
05.01.2017100Delhi
06.01.2017100Delhi
01.01.2017101Delhi
02.01.2017101Delhi
03.01.2017101Delhi
04.01.2017101Delhi
05.01.2017101Delhi
06.01.2017101Delhi
08.01.2017101Delhi
09.01.2017102Chennai
01.01.2017102Chennai
02.01.2017102Chennai
03.01.2017102Chennai
04.01.2017102Chennai
05.01.2017102Chennai
06.01.2017102Chennai
08.01.2017102Chennai
11.01.2017102Chennai
01.02.2017101Delhi
02.02.2017101Delhi
03.02.2017101Delhi
04.02.2017101Delhi
05.02.2017101Delhi
06.02.2017101Delhi
01.02.2017100Delhi
02.02.2017100Delhi
03.02.2017100Delhi
04.02.2017100Delhi
05.02.2017100Delhi
06.02.2017100Delhi
01.02.2017102Chennai
02.02.2017102Chennai
03.02.2017102Chennai
04.02.2017102Chennai
05.02.2017102Chennai
06.02.2017102Chennai
01.02.2017103Goa
02.02.2017103Goa
03.02.2017103Goa
04.02.2017103Goa
05.02.2017103Goa
06.02.2017103Goa
01.02.2017104Goa
02.02.2017104Goa
03.02.2017104Goa
04.02.2017104Goa
01.03.2017100Delhi
02.03.2017100Delhi
03.03.2017100Delhi
04.03.2017100Delhi
05.03.2017100Delhi
06.03.2017100Delhi
01.03.2017101Delhi
02.03.2017101Delhi
03.03.2017101Delhi
04.03.2017101Delhi
05.03.2017101Delhi
06.03.2017101Delhi
08.03.2017101Delhi
09.03.2017102Chennai
01.03.2017102Chennai
02.03.2017102Chennai
03.03.2017102Chennai
04.03.2017102Chennai
05.03.2017102Chennai
1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @deb_power123 

 

According to your description, It's not hard to do. You can use 'DISTINCTCOUNT' in ID column instead of date column.

Like this:

Measure 2 = DISTINCTCOUNT(TableA[StudentID])

2.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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
v-janeyg-msft
Community Support
Community Support

Hi, @deb_power123 

 

According to your description, It's not hard to do. You can use 'DISTINCTCOUNT' in ID column instead of date column.

Like this:

Measure 2 = DISTINCTCOUNT(TableA[StudentID])

2.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

amitchandak
Super User
Super User

@deb_power123 , Try one of the measure

 

countx(values(Table[Location]), calculate(distinctCOUNT(Table[StudentID])))

 

or

 

countx(summarize(Table, Table[Location], Table[Date].Month, "_1",calculate(distinctCOUNT(Table[StudentID]))),[_1])

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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