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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

multiple conditions + calculation

Hi Community,

 

following problem.

My calculation with multiple conditions including addition does not work

 

 

 

Here is my formula that doesn't work:

 

 If(and( Category ="Küche" && Order >(Date(2021, 12, 31) && Order < (Date(2022, 12, 31), Calculate(0*200) +

 If(and( Category ="Küche" && Shiptment>(Date(2021, 12, 31) && Order < (Date(2022, 12, 31), Calculate(0,25*200) + 

If(and( Category ="Küche" && IBN>(Date(2021, 12, 31) && Order < (Date(2022, 12, 31), Calculate(0,5*200) +

If(and( Category ="Küche" && Ready>(Date(2021, 12, 31) && Order < (Date(2022, 12, 31), Calculate(0,25*200) )))

 

PBI 1.jpg

 

 

Does anyone have an idea how I can do this calculation in Power BI?

 

 

 

19 REPLIES 19
Anonymous
Not applicable

@Anonymous  I think you have uploaded it on your office drive and we dont have access to it. Better try to give access to all or use wetranfer.com or similar to it.

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

Create a column with below code

Column =
SWITCH (
    TRUE (),
    Category = "Küche"
        && Order > DATE ( 2021, 12, 31 )
        && Order < DATE ( 2022, 12, 31 ), 0 * 200,
    Category = "Küche"
        && Shiptment > DATE ( 2021, 12, 31 )
        && Order < DATE ( 2022, 12, 31 ), 0.25 * 200,
    Category = "Küche"
        && Shiptment > DATE ( 2021, 12, 31 )
        && Order < DATE ( 2022, 12, 31 ), 0.25 * 200,
    Category = "Küche"
        && IBN > DATE ( 2021, 12, 31 )
        && Order < DATE ( 2022, 12, 31 ), 0.5 * 200,
    Category = "Küche"
        && Ready > DATE ( 2021, 12, 31 )
        && Order < DATE ( 2022, 12, 31 ), 0.25 * 200
)

 

and then create a measure like below or directly used new column as summerized as sum

 

Measure = Sum(table[column])

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Thanks for your help - Unfortunately it doesn't work.

Test2222.jpg

@Syndicate_Admin , Remove last comma(",") from the last line i.e. line 28.

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

000112.jpg

@Anonymous is it possible for you to share PBIX file after removing sensitive data?

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Yes, it is possible, so I have created a sample PBI file. How can I send them to you?

@Syndicate_Admin  upload it in any suitable drive and share the URL. 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

@Syndicate_Admin Not accessible.

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

@Olboss_384 , Please try this:-

 

 

 

Column = 
if(Tabelle2[category] = "küche"&& Tabelle2[Order]  > DATE ( 2021, 12, 31 )&& Tabelle2[Order] < DATE ( 2022, 12, 31 ), 0 * 200,

if(Tabelle2[category] = "küche"&& Tabelle2[Shipment]  > DATE ( 2021, 12, 31 )&& Tabelle2[Shipment] < DATE ( 2022, 12, 31 ), 0.25 * 200,

IF( [category] = "küche" && [IBN]  > DATE ( 2021, 12, 31 ) && [IBN] < DATE ( 2022, 12, 31 ), 0.5 * 200,

if(Tabelle2[category] = "küche"&& Tabelle2[Ready]  > DATE ( 2021, 12, 31 )&& Tabelle2[Ready] < DATE ( 2022, 12, 31 ), 0.5 * 200,

if(Tabelle2[category] = "Bad"&& Tabelle2[Order]  > DATE ( 2021, 12, 31 )&& Tabelle2[Order] < DATE ( 2022, 12, 31 ), 0 * 200,

if(Tabelle2[category] = "Bad"&& Tabelle2[Shipment]  > DATE ( 2021, 12, 31 )&& Tabelle2[Shipment] < DATE ( 2022, 12, 31 ), 0.25 * 200,

if(Tabelle2[category] = "Bad"&& Tabelle2[IBN]  > DATE ( 2021, 12, 31 )&& Tabelle2[IBN] < DATE ( 2022, 12, 31 ), 0.5 * 200,

if(Tabelle2[category] = "Bad"&& Tabelle2[Ready]  > DATE ( 2021, 12, 31 )&& Tabelle2[Ready] < DATE ( 2022, 12, 31 ), 0.5 * 200

))))))))

 

 

 

Departure:-

Samarth_18_0-1642756406420.png

 

Thank you

Samarth

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Thank you for the help, it works.

Is it possible to define the date in the code as a variable so that I do not have to write this out?

--> In case I need to change the date, I would only have to do this in the variable and not in every line.

For example

000114.jpg

@Syndicate_Admin Okay try this then:-

Column = 
var _yr_2021 = DATE ( 2021, 12, 31 )
var _yr_2022 = DATE ( 2022, 12, 31 )
return if(Tabelle2[category] = "küche"&& Tabelle2[Order]  > _yr_2021&& Tabelle2[Order] < _yr_2022, 0 * 200,

if(Tabelle2[category] = "küche"&& Tabelle2[Shipment]  > _yr_2021&& Tabelle2[Shipment] < _yr_2022, 0.25 * 200,

IF( [category] = "küche" && [IBN]  > _yr_2021 && [IBN] < _yr_2022, 0.5 * 200,

if(Tabelle2[category] = "küche"&& Tabelle2[Ready]  > _yr_2021&& Tabelle2[Ready] < _yr_2022, 0.5 * 200,

if(Tabelle2[category] = "Bad"&& Tabelle2[Order]  > _yr_2021&& Tabelle2[Order] < _yr_2022, 0 * 200,

if(Tabelle2[category] = "Bad"&& Tabelle2[Shipment]  > _yr_2021&& Tabelle2[Shipment] < _yr_2022, 0.25 * 200,

if(Tabelle2[category] = "Bad"&& Tabelle2[IBN]  > _yr_2021&& Tabelle2[IBN] < _yr_2022, 0.5 * 200,

if(Tabelle2[category] = "Bad"&& Tabelle2[Ready]  > _yr_2021&& Tabelle2[Ready] < _yr_2022, 0.5 * 200

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hi, I just noticed that the values are not added up.

Can you please help me again.

000115.jpg

@Syndicate_Admin , It is not required. You can directly use this column on your visual and mark summerization as SUM  or create a measure with below code and use it:-

measure = Sum(Tabelle2[column])

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

Thank you. But I do not want to make the sum of all projects, such as summerization.

Calculation within the formula would need to be adjusted.
In the formula the result is 100, but it should be 200.

 

 

 

 

000116.jpg

Helpful resources

Announcements
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.

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.