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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Gingerjeans88
Helper IV
Helper IV

DAX Measure help! % calculation

Hello hello helpful folk, 

 

I need a little help with a measure. 
I'll give you the high level requirement then explain table structure:

 

I need to be able to calculate the % of college applicants who attended a careers day before they applied. 
Every student has a Student record in the Student table [StudentId], which is related to the Applications table [StudentValueID] by a 1:N relationship. They can have multiple but mostly just have one, and we're concerned with their first application anyhow. 
Their attendance at a Careers Day is recorded by an Event Response record with a [Type] of 'Careers Day', these responses are child records of an Events table (1:N). 

Essentially - I want to see the percentage of students with an event response, where the event response date is earlier than the date of their application. 

Can provide visuals of table structure if needed but hopefully the above is explanatory enough! 

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one way to approach this one

 

% Students Career Day First =
VAR __summarytable =
    ADDCOLUMNS (
        VALUES ( Students[StudentID] ),
        "@AppDate", CALCULATE ( MIN ( Applications[Date] ) ),
        "@MinCareerDay", CALCULATE ( MIN ( Events[Date] ), Events[Type] = "Careers Day" )
    )
RETURN
    DIVIDE (
        COUNTROWS ( FILTER ( __summarytable, [@MinCareerDay] < [@AppDate] ) ),
        COUNTROWS ( __summarytable )
    )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Share data in a format that can be pasted in an Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one way to approach this one

 

% Students Career Day First =
VAR __summarytable =
    ADDCOLUMNS (
        VALUES ( Students[StudentID] ),
        "@AppDate", CALCULATE ( MIN ( Applications[Date] ) ),
        "@MinCareerDay", CALCULATE ( MIN ( Events[Date] ), Events[Type] = "Careers Day" )
    )
RETURN
    DIVIDE (
        COUNTROWS ( FILTER ( __summarytable, [@MinCareerDay] < [@AppDate] ) ),
        COUNTROWS ( __summarytable )
    )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi Pat @mahoneypat 

 

You are a star, thank you! However - the Event Date is on the Event, and I need to return the Students with an Event Responses where the related Event's date is before the earliest application date. I'm not sure the @ MinOpenDay is doing this? What do you think?

I have, however, pulled the related Event's date onto each Event Response with a calculated column, so I now have:

 

Event Responses [Event Date] as a calculated column,

as well as Students[EarliestApplicationDate] to avoid needing to evaluate across all Students' application records. This could simplify the measure but wouldn't work as well with a summary table no?

I think it is doing that comparison in the filter part in the return statement. Please let me know if you are getting incorrect results.

Regards

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Gingerjeans88
Helper IV
Helper IV

Quick clarification /amendment because of a typo:

*Essentially I want to see the percentage of students with a Careers Day event response, where the careers day event response date is earlier than the date of their application. 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors