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
Olboss_384
Helper I
Helper I

Calculation IF Fuction

Hi Community

as you can see in the picture attached below, my formula is not working properly.

Does anyone have any idea how I can adjust my formula to show the correct result in each row.

or should I use a measure here?

 

Hope you can help me with this 🙂

 

Testfile --> https://www.transfernow.net/dl/202201267L8uSdBw

 

IF-Function

within 2022 =
var _yr_2021 = DATE ( 2021, 12, 31 )
var _yr_2022 = DATE ( 2022, 12, 31 )
 
return if(
data[category] = "Küche"&& data[Shipment] > _yr_2021&& data[Shipment] < _yr_2022, 0.25 * 200,
IF( [category] = "Küche" && data[IBN] > _yr_2021 && data[IBN] < _yr_2022, 0.5 * 200,
if(data[category] = "Küche"&& data[Ready] > _yr_2021&& data[Ready] < _yr_2022, 0.25 * 200,

IF(data[category] = "Bad"&& data[Shipment] > _yr_2021&& data[Shipment] < _yr_2022, 0.25 * 300,
IF( [category] = "Bad" && data[IBN] > _yr_2021 && data[IBN] < _yr_2022, 0.5 * 300,
if(data[category] = "Bad"&& data[Ready] > _yr_2021&& data[Ready] < _yr_2022, 0.25 * 300
))))))

 

 

000118.jpg

1 REPLY 1
lbendlin
Super User
Super User

@Olboss_384 Please confirm if this is for Power BI Report Server or for the service.

Here is a cleaned up and corrected version of the calculated column according to your requirement.

 

within 2022 = 
var _yr_2021 = DATE ( 2021, 12, 31 )
var _yr_2022 = DATE ( 2022, 12, 31 )
return 200*(data[category] = "Küche")*
  ((data[Shipment]  > _yr_2021 && data[Shipment] < _yr_2022)*0.25+
  (data[IBN]  > _yr_2021 && data[IBN] < _yr_2022)*0.5+
  (data[Ready]  > _yr_2021 && data[Ready] < _yr_2022)*0.25)
+300*(data[category] = "Bad")*
  ((data[Shipment]  > _yr_2021 && data[Shipment] < _yr_2022)*0.25+
  (data[IBN]  > _yr_2021 && data[IBN] < _yr_2022)*0.5+
  (data[Ready]  > _yr_2021&& data[Ready] < _yr_2022)*0.25)

 

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.