- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

cross table query to find different grades for student
Greetings! I'd like some help with the following issue.
We have three tables for storing students' grades across different moments. The three tables are the same, only the column "Period" has disctinctive data. The structure is similar to this:
So, when a student fails period A1, s/he has the opportunity at period A2, and later at A3. is there a way to trace the students with failed grades and generate a new column with the final grade after the three periods? this is just an example, the real data is 1.3 million rows of data.
Note, for us a grade of 5 equals a Failed subject
Your help will be greatly appreciated!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @Hatterg
@Greg_Deckler Very interesting idea!
For your question, here is the method I provided:
Here's some dummy data
"PeriodA1"
"PeriodA2"
"PeriodA3"
Since your data is spread across three tables with similar structures, the first step is to merge these tables into one. This can be accomplished using Merge Query as New in Power Query.
Create a measure to calculation of final grades.
Final Grade =
IF(
SELECTEDVALUE(ConsolidatedGrades[PeriodA1]) > 5,
VALUES(ConsolidatedGrades[PeriodA1]),
IF(
SELECTEDVALUE(ConsolidatedGrades[PeriodA2]) > 5,
VALUES(ConsolidatedGrades[PeriodA2]),
IF(
SELECTEDVALUE(ConsolidatedGrades[PeriodA3]) > 5,
VALUES(ConsolidatedGrades[PeriodA3]),
BLANK()
)
)
)
Or you can create a calculated column.
Final Grades =
IF(
ConsolidatedGrades[PeriodA1] > 5,
ConsolidatedGrades[PeriodA1],
IF(
ConsolidatedGrades[PeriodA2] > 5,
ConsolidatedGrades[PeriodA2],
IF(
ConsolidatedGrades[PeriodA3] > 5,
ConsolidatedGrades[PeriodA3],
BLANK()
)
)
)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @Hatterg
@Greg_Deckler Very interesting idea!
For your question, here is the method I provided:
Here's some dummy data
"PeriodA1"
"PeriodA2"
"PeriodA3"
Since your data is spread across three tables with similar structures, the first step is to merge these tables into one. This can be accomplished using Merge Query as New in Power Query.
Create a measure to calculation of final grades.
Final Grade =
IF(
SELECTEDVALUE(ConsolidatedGrades[PeriodA1]) > 5,
VALUES(ConsolidatedGrades[PeriodA1]),
IF(
SELECTEDVALUE(ConsolidatedGrades[PeriodA2]) > 5,
VALUES(ConsolidatedGrades[PeriodA2]),
IF(
SELECTEDVALUE(ConsolidatedGrades[PeriodA3]) > 5,
VALUES(ConsolidatedGrades[PeriodA3]),
BLANK()
)
)
)
Or you can create a calculated column.
Final Grades =
IF(
ConsolidatedGrades[PeriodA1] > 5,
ConsolidatedGrades[PeriodA1],
IF(
ConsolidatedGrades[PeriodA2] > 5,
ConsolidatedGrades[PeriodA2],
IF(
ConsolidatedGrades[PeriodA3] > 5,
ConsolidatedGrades[PeriodA3],
BLANK()
)
)
)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Hatterg Can you post that data as text so it can be copied and pasted into Enter data queries so that this can be mocked up? Also, is there any reason you can't combine those three tables into a single table using an Append query?
Follow on LinkedIn
@ 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!: Power BI Cookbook Third Edition (Color)
DAX is easy, CALCULATE makes DAX hard...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank's for your reply @Greg_Deckler . I can definitely append the tables, but after that I hit wall trying to obtain the final grade after the three periods thats why I thought about the possibility of a conditional column or something similar.
Sure, here is the data as text:
Id | Name | Last Name | Subject | Grade | Period |
1 | Carol | Danvers | Math | 5 | A1 |
2 | Tony | Stark | Math | 9 | A1 |
3 | Peter | Parker | Math | 5 | A1 |
1 | Carol | Danvers | Language | 6 | A1 |
2 | Tony | Stark | Language | 8 | A1 |
3 | Peter | Parker | Language | 5 | A1 |
1 | Carol | Danvers | Art | 7 | A1 |
2 | Tony | Stark | Art | 9 | A1 |
3 | Peter | Parker | Art | 10 | A1 |
1 | Carol | Danvers | Science | 5 | A1 |
2 | Tony | Stark | Science | 7 | A1 |
3 | Peter | Parker | Science | 9 | A1 |
Id | Name | Last Name | Subject | Grade | Period |
1 | Carol | Danvers | Math | 8 | A2 |
3 | Peter | Parker | Math | 5 | A2 |
3 | Peter | Parker | Language | 9 | A2 |
1 | Carol | Danvers | Science | 5 | A2 |
Id | Name | Last Name | Subject | Grade | Period |
3 | Peter | Parker | Math | 8 | A3 |
1 | Carol | Danvers | Science | 6 | A3 |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Based on the 3 tables that you have shared, show the expected result.
Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
11-08-2020 03:16 AM | |||
04-10-2024 06:10 AM | |||
Anonymous
| 06-07-2023 09:16 AM | ||
11-28-2023 10:50 PM | |||
06-14-2023 05:59 AM |