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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Conditional calculation

Hi there,

I have a task where i have to calculate electrical tariff. However i cant get pass through getting the DAX codes right for the conditional calculation, i would appreciate some help.

 

What i want to achieve is:

1. If total consumption is below 200 kwh, the total consumption will be multiplied by 0.435

2. If the total consumption is more than 200 kwh,

    The first 200kwh will be multiplied by 0.435 and value over 200kwh will be multiplied by 0.509

 

 

 

 

1 ACCEPTED SOLUTION
bcdobbs
Community Champion
Community Champion

Assuming you have an existing measure for [Total Consumption] I think the following works:

Electrical Tariff = 
VAR TotalConsumption = [Total Consumption]

VAR Result =
	IF (
		TotalConsumption <= 200,
		TotalConsumption * 0.435,
		(200 * 0.435) + (TotalConsumption - 200)*0.509
		)
		
RETURN Result


Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you so much, works well for me !

bcdobbs
Community Champion
Community Champion

Assuming you have an existing measure for [Total Consumption] I think the following works:

Electrical Tariff = 
VAR TotalConsumption = [Total Consumption]

VAR Result =
	IF (
		TotalConsumption <= 200,
		TotalConsumption * 0.435,
		(200 * 0.435) + (TotalConsumption - 200)*0.509
		)
		
RETURN Result


Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.