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
lukeSDM
Helper V
Helper V

wrong calculation and not showing in graph correctly

@AllisonKennedy  maybe you will know the answer

 

I am trying to work out the attendance percentage for each student over time.

Each Adno number (student) gets 2 attendance marks for each date for the AM and the PM the marks are as follows ; / - present in the AM, \ - present in the PM, I - ill/authorised absence, O - unauthorised absence ETC.

I have a calculation that calculates the two present marks (/ &\) and then I divide this by the count of all rows.

However when I do this it only gives me a result of 50% or 100% ie if they are present for the whole day and if they get 1 present mark they get 50% but when they are not present that day I would like it to go to zero% 

i have fixed my graph so that it shows all days but when the % should be zero it just skips across so i have an inconplete line!

Any help would be really appreciated and I have attached some images to provide some context.here you can see a specific student was not present at all that day but the line stops instead of going to zerohere you can see a specific student was not present at all that day but the line stops instead of going to zeroattendance2.PNG

 

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

hi  @lukeSDM 

Add a date table by this formula:

Date = CALENDAR(MIN('Attendance overtime'[Mark date]),MAX('Attendance overtime'[Mark date]))

Then create a relationship with [Mark date]

1.JPG

 

and adjust the measure as below:

/\ % = [count of /\] / COUNTA('Attendance overtime'[Mark]) *100 + 0

 

Now use date field from date table in the x-axis in line visual.

 

Result:

2.JPG

 

here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
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

9 REPLIES 9
v-lili6-msft
Community Support
Community Support

hi  @lukeSDM 

Add a date table by this formula:

Date = CALENDAR(MIN('Attendance overtime'[Mark date]),MAX('Attendance overtime'[Mark date]))

Then create a relationship with [Mark date]

1.JPG

 

and adjust the measure as below:

/\ % = [count of /\] / COUNTA('Attendance overtime'[Mark]) *100 + 0

 

Now use date field from date table in the x-axis in line visual.

 

Result:

2.JPG

 

here is sample pbix file, please try it.

 

Regards,

Lin

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

Thank you this has resolved my issue!

hi  @lukeSDM 

It's pleasant that your problem has been solved, 😁 could you please mark the reply as Answered?

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
negi007
Community Champion
Community Champion

@lukeSDM  I think your Y axis is starting from 50%. Please change it to start from 0 (Zero), your chart will apear as you want.

 

Axis.PNG




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Unfortunately this was not the case!

Capture.PNG

negi007
Community Champion
Community Champion

@lukeSDM  Can you try using below DAX in your measure

 

Count = (CALCULATE(COUNTROWS('Marks_tab'),'Marks_tab'[Mark] in {"/","\"}))/(CALCULATE(COUNTROWS('Marks_tab'),ALL('Marks_tab'[Mark])))


Axis.PNG



Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

@negi007 

Unfortunately this still does not resolve my issue, as it does not go to 0% when the student has no present marks for that day.

I need it so when they are presant all day (2present marks out of 2, 1 for am and one for pm) it is 100% for that day, then when they are presant half the day ( 1 presant mark out of 2 ) it equals 50% and then when they are not present for that day (0 presant marks out of 2) it is 0%. 

That is essentially what i need.

I might need to use the statistical meaning instead of the mark as well due to 'L' also being present but technically they are late. so it might be worth counting the statistical meaning instead of the mark itself.

 

amitchandak
Super User
Super User

@lukeSDM ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Please find the spreadsheet my data comes from.

my measure for counting the present mark is : 

count of /\ = CALCULATE(COUNTROWS('Attendance overtime'),'Attendance overtime'[Mark] IN {"/", "\"})
 
and i work the % out by doing:
/\ % = [count of /\] / COUNTA('Attendance overtime'[Mark]) *100
 
AdnoMarkMark dateAM/PMStatistical meaning
384742L07 January 2020AMPresent
384742\07 January 2020PMPresent
384742U08 January 2020AMUnauthorised Absence
384742\08 January 2020PMPresent
384742L09 January 2020AMPresent
384742\09 January 2020PMPresent
384742/10 January 2020AMPresent
384742\10 January 2020PMPresent
384742/13 January 2020AMPresent
384742\13 January 2020PMPresent
384742/14 January 2020AMPresent
384742\14 January 2020PMPresent
384742/15 January 2020AMPresent
384742\15 January 2020PMPresent
384742L16 January 2020AMPresent
384742\16 January 2020PMPresent
384742/17 January 2020AMPresent
384742\17 January 2020PMPresent
384742/20 January 2020AMPresent
384742L20 January 2020PMPresent
384742/21 January 2020AMPresent
384742\21 January 2020PMPresent
384742/22 January 2020AMPresent
384742\22 January 2020PMPresent
384742/23 January 2020AMPresent
384742\23 January 2020PMPresent
384742L24 January 2020AMPresent
384742\24 January 2020PMPresent
384742/27 January 2020AMPresent
384742\27 January 2020PMPresent
 
 

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.