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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. 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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.