Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi, I am looking for help if it is possible to add a column value based on the values from two other columns.
I have two possible values for the Class Name column based on the Course Name and whether a student is in 7 or 8 Grade.
The Class Name values need to be either "7 Mathematics" or "8 Mathematics". The first image below is what I am hoping for it to look like.
If this addition below can be added it would be fantastic!
If the Course Name value is any of these with the green checks that name would just be duplicated in the Class Name column.
So basically copy the Course Name values to the Class Name column unless they are math classes and then assign either of the two corrected values.
Solved! Go to Solution.
1. Identify a primary key in your data. In your case that is a composite key made up of Course Name and Student Grade which I implemented as a calculated column
2. Right click on that primary key column and create (or edit) a group. Now you can bucket collections of primary keys into your Class groups.
3. Use the Class groups column in your visuals.
The same can be achieved with lots of code in either Power Query or DAX, but the column group method is more convenient, and it is sufficient if you don't expect your data to change frequently.
@lbendlin Thank you very much for your continued help. Below is some sample data with the results field being the Class Name column. Most of the values are the same as the Course Name column. All students need to be in either 7 Mathematics or 8 Mathematics based on their grade level and regardless of what actual math class they are in.
Course Name | Student Grade | Class Name |
7 English | 7 | 7 English |
7 Integrated Science | 7 | 7 Integrated Science |
7 Language Arts | 7 | 7 Language Arts |
7 Mathematics | 7 | 7 Mathematics |
7/8 Algebra I | 7 | 7 Mathematics |
7/8 Algebra I | 8 | 8 Mathematics |
8 English | 8 | 8 English |
8 Integrated Science | 8 | 8 Integrated Science |
8 Language Arts | 8 | 8 Language Arts |
8 Mathematics | 8 | 8 Mathematics |
Algebra II/Trig | 8 | 8 Mathematics |
Hon. Algebra II/Trig | 8 | 8 Mathematics |
@lbendlin That looks fantastic! I appreciate you. Could you give me a quick explanation of how the "Class Name" column gets the values?
1. Identify a primary key in your data. In your case that is a composite key made up of Course Name and Student Grade which I implemented as a calculated column
2. Right click on that primary key column and create (or edit) a group. Now you can bucket collections of primary keys into your Class groups.
3. Use the Class groups column in your visuals.
The same can be achieved with lots of code in either Power Query or DAX, but the column group method is more convenient, and it is sufficient if you don't expect your data to change frequently.
@lbendlin I did some reading on that and appreciate you steering me to a totally new area that I have not used in PBI before. I still cannot figure out how to apply that to my desired outcome.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523
Read about Column Groups. Much easier to create and maintain.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
144 | |
75 | |
63 | |
51 | |
48 |
User | Count |
---|---|
204 | |
86 | |
64 | |
59 | |
56 |