cancel
Showing results 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.

New Member

## 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!

1 ACCEPTED SOLUTION
Community Support

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(
IF(
IF(
BLANK()
)
)
)``````

Or you can create a calculated column.

``````Final Grades =
IF(
IF(
IF(
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.

4 REPLIES 4
Community Support

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(
IF(
IF(
BLANK()
)
)
)``````

Or you can create a calculated column.

``````Final Grades =
IF(
IF(
IF(
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.

Super User

@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?

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
New Member

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
Super User

Hi,

Based on the 3 tables that you have shared, show the expected result.

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### 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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors