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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
o59393
Post Prodigy
Post Prodigy

Convert Calculated Column into Dax Measure (IF vs Switch)

Hi all

 

I have a calculated column which gives the correct result; however, it's making my model very heavy in size, therefore I'd like to optimize it with Dax. 

 

I am using 2 alternatives in dax to eliminate the calculated column. 

 

First option is nested IFs and the second one is Switch & True.  What I have noticed is that IF is very slow compared to Switch.

 

As seen below, the Year 1 matches row by row but the totals for the IF measure, Switch measure and Calculated Column.

 

o59393_0-1696187059531.png

 

For year 2:

 

o59393_1-1696187118767.png

 

 

For the IF the results row by row are ok, but the total is incorrect. The Switch measure is incorrect in both rows and total.

 

How can I have both the IF and Switch return the correct values per row and the total too for year 2? The correct result is the calculated column.

 

I attach a sample PBIX and xls to make it easier.

 

sample_data_1.xlsx

sample_data_1.pbix

 

Thanks!!

 

 

1 REPLY 1
o59393
Post Prodigy
Post Prodigy

As an update, I changed in the relationship direction to "both" instead of "single" and now the results row by row seem ok.

 

The only thing I would need help is in getting the total value correct.


Thanks.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors