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
CalClack
Helper II
Helper II

Substitute Value using If Then Else

I would like to a calculated column value from one table if condition is true, else use a column value from another table if false. For instance in the screen shot if Ithere is a value > 0.00, I'd like to use the value,  from one table, G Calculated Electricity % dimPeriod into the column "NewElec%", otherwise use the value, G Calculated Electric % factMeterReading from a second table.  My statement for the calculated column is:

 

NewElec% = IF(max('dim_Period'[G Calculated Electricity % dimPeriod]) > 0.00,
(max('dim_Period'[G Calculated Electricity % dimPeriod])),
(max('fact_MeterReading'[G Calculated Electric % factMeterReading]))
)

 

 

 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi. First, there's no screenshot. Second, a calculated column like this should be created and calculated during the ETL phase, possibly in Power Query. Calculated columns are not compressed optimally when created with DAX.

Best
D

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi. First, there's no screenshot. Second, a calculated column like this should be created and calculated during the ETL phase, possibly in Power Query. Calculated columns are not compressed optimally when created with DAX.

Best
D

Thanks, I will take a look at the ETL phase of calculating.

az38
Community Champion
Community Champion

Hi @CalClack 

try smth like

NewElec% = 
var _maxDimPeriod = CALCULATE(max('dim_Period'[G Calculated Electricity % dimPeriod]))

RETURN
IF(_maxDimPeriod  > 0,
_maxDimPeriod ,
max('fact_MeterReading'[G Calculated Electric % factMeterReading])
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

AZ38,

 

I'd like to pursue your proposed solution, but I'm not understanding the format you have propsed.  I should have probably attacked it from the backend at the database level, but if you technique works, then that would be another feather in the hat.

IfThenElse.png

 

IfThenElse.png

I'll give it a shot.  Thanks for the rapid reply

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.