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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

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

@Anonymous 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 carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.