- 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
CASE Statement to DAX
So I have the below:
CASE
WHEN [Academic Career] = Undergraduate THEN [CGPA UG]
WHEN [Academic Career] = Masters THEN [CGPA GR]
ELSE 'No CGPA'
END
How do I change this into DAX for Power BI? Is such an approach possible in DAX? [Academic Career], [CGPA UG], and [CGPA GR] are columns. I want to create a new column that grabs the value from each of those two columns based on the case statement.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was in a hurry and didn't close my parentheses.
MeasureorColumn= SWITCH( Table[Academic Career], "Undergraduate",FORMAT(Table[CGPA UG], "General Number"), "Masters", FORMAT(Table[CGPA GR], "General Number"), "No CGPA" )
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So if I understand you correctly, you have 2 columns for different levels of CGPA undergrad and grad, and you want to merge them into one column that shows what was in CGPA UG if they're an undergrad and CGPA GR if they're a grad student. Is that correct?
CGPAMerged = SWITCH( TableName[Academic Career], "Undergraduate", TableName[CGPA UG], "Master's", TableName[CGPA GR], BLANK() )
This would give you a single column that would merge the 2 based on the student's level in column AB in your sample data. The last argument returns blank if their career is anything other than undergraduate or master's. Then a simple measure like
Avg CGPA = AVERAGE(TableName[CGPAMerged])
...would give you the average per plan if you placed it on a chart along with column AC.
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know of any reason for that. The new CGPAMerged column you created is on the same table as Academic Plan, just like in the sample data, right? And the measure is an average of that new column?
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, thats correct. I rechecked all of the slicers and they affect all other visuals presented in the dashboard. I don't see anything special that would stop it from also impacting the Card.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know of any reason for that. The new CGPAMerged column you created is on the same table as Academic Plan, just like in the sample data, right? And the measure is an average of that new column?
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, thats correct. I am only working from one table. Possibly a bug in Power BI?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't think so. There's something we're missing here. Have you run through that new column to make sure that it has the correct values?
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just did a quick scan through and it grab the CGPA from the correct column to add to the new column. Its formatted as a Decimal Number. None of the cells are blank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It has to be visual interactions then, somehow. Can I see a screenshot of them?
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure see below. When I change to a table and put the academic plans on the rows and the AVG CGPA on the Column it does show the Average CGPA by program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What if you just change the card to a table visual and don't put anything else on it? Just leave everything else alone. Does the slicer change it then?
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Correct, I just changed to a table and didn't do anything. I also tried Matrix. It seems that anything we do concerning the MergedCGPA column and the Average of that don't change with everything else in the dashboard based on the Slicer selection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There has to be something else about this data model that I can't see that's causing this. At this point I don't know what else to suggest without seeing the actual pbix file myself.
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
this was just an awesome post than you for sharing bpcreditcard, mybpcreditcard.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A slicer of [Academic Year] does change the number. But how do I make sure that I am getting an average of distinct student CGPA. Even though their name appears multiple times the CGPA value stays the same since its a year end CGPA.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try changing your measure to
Avg CGPA = AVERAGEX( VALUES(TableName[Student ID]), AVERAGE(TableName[CGPAMerge]) )
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I still don't understand what's causing it to behave that way though. That slicer should work fine with that measure even if there's no year selected. Look, here's your sample data in a quick file I put together using the regular average formula. https://drive.google.com/open?id=0B9BEw2M_e_jvT2I0TWxKRTZpdjA
I have a card with the Avg CGPA measure and an Academic Plan slicer. They interact exactly as expected. Can you look at this and tell me what's different between my file and yours?
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok so I just deleted all the slicers and recreated them and now its work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am going through line-by-line and comparing to your setup. Hoping that I would find something different to put an end to this nightmare but so far I have found nothing different. The only thing is I have 270,000 lines but the format is the same as the sample file I gave you just with some students appearing 3 or 4 times per academic year.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not certain if this would have any impact but since its a registration report for the students each row represents a registration so if a student has 4 registrations for that academic year then they would have 4 rows showing the same information just different information in the course column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FERPA Law stands in front of me and completion! I will keep playing with it to see if I can find anything that stands out. The column is grabbing the correct number. They are all formatted the same as decimals with 2 digits after the decimal. If a person has 0 in both columns CGPA UG and GR it is pulling a 0 over into the new column.

Helpful resources
Subject | Author | Posted | |
---|---|---|---|
02-01-2023 11:59 AM | |||
Anonymous
| 10-15-2020 12:14 PM | ||
Anonymous
| 01-23-2020 12:46 PM | ||
04-19-2023 12:53 PM | |||
08-22-2018 10:49 AM |
User | Count |
---|---|
128 | |
123 | |
85 | |
59 | |
47 |