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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
RachelB
New Member

Attendance - new column - Calculate function

Hi, I am relatively new to PBi but have done a basic skills course and half way through the intermediate one.  I have created a report for school attendance and am trying to add a column to my Pupils data table which brings in the prior year attendance for each pupil.    I have used a Calculate formula (see below), which brings in the % attendance from my Measures table, and links to the Dates table.   The formula seems to be OK, as no error message has been generated, but no data is showing in the table.  Any ideas on what I am doing wrong?   Thank you.

 

% Attend Last Year = CALCULATE('Attendance Measures'[% Attend for period],PREVIOUSYEAR('Attendance Dates'[Date],"31/08/2023"))
1 REPLY 1
123abc
Community Champion
Community Champion

Here are a few things to check:

  1. Relationships: Ensure that there is a proper relationship between the tables involved (Pupils, Attendance Measures, and Attendance Dates). The relationship should be based on the date fields so that the calculation can flow correctly.

  2. Date Filtering: Verify that your date filtering works as intended. The PREVIOUSYEAR function requires a date column. Ensure that your [Date] column in the Attendance Dates table contains appropriate date values.

  3. Date Format: Make sure that the date format in your DAX function matches the format stored in your [Date] column. If your dates are stored as Date type, you should use a date format like DATE(2023, 8, 31) instead of "31/08/2023".

Here's the revised version of your DAX formula:

 

% Attend Last Year =
CALCULATE(
'Attendance Measures'[% Attend for period],
PREVIOUSYEAR('Attendance Dates'[Date])
)

 

If your PREVIOUSYEAR function is correctly set up, this formula should calculate the attendance percentage for each pupil for the previous year based on the dates in your Attendance Dates table.

If you're still encountering issues, it might be helpful to break down your problem further and check the individual components to identify where the problem lies. You can try testing each part of your formula separately in a DAX expression window to see if they return the expected results.

 

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

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.