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
weberna
Frequent Visitor

replace cell value with conditional value and multiply to output value

Hello all,
I am new to power bi and need help with a calculation.

I have three columns: "Anzahl Lieferanten", "Anzahl Hersteller" and "Zeit bis EOL" (in days). Now I want to assign a value from 1-3 to each of the values in the columns if they are greater or less than certain values. the resulting values I then want to multiply.
I have thought of something like this:

 

weberna_0-1655463944465.png

 

 

Of course, it doesn't work that way. Maybe someone can help me? Thanks in advance!

 

1 ACCEPTED SOLUTION
rohit_singh
Solution Sage
Solution Sage

Hello @weberna ,

The issue is with the syntax of the switch statement.

rohit_singh_0-1655470434319.png

Obsoleszenzwahrscheinlichkeit =

var Lieferantenrisiko =
SWITCH(
TRUE(),
Inventory[Anzahl Lieferanten] = 1, 3,
Inventory[Anzahl Lieferanten] > 1 && Inventory[Anzahl Lieferanten] < 4, 2,
Inventory[Anzahl Lieferanten] > 3, 1
)


var Herstellerrisiko =
SWITCH(
TRUE(),
Inventory[Anzahl Hersteller] = 1, 3,
Inventory[Anzahl Hersteller] > 1 && Inventory[Anzahl Hersteller] < 4, 2,
Inventory[Anzahl Hersteller] > 3, 1
)

var EOLRisiko =
SWITCH(
TRUE(),
Inventory[Zeit bis EOL] < 365, 1,
Inventory[Zeit bis EOL] >= 365 && Inventory[Zeit bis EOL] <= 730, 2,
Inventory[Zeit bis EOL] > 730, 3
)

var result =
(2 * Lieferantenrisiko) * Herstellerrisiko * EOLRisiko

Return
result
 

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

View solution in original post

3 REPLIES 3
rohit_singh
Solution Sage
Solution Sage

Hello @weberna ,

The issue is with the syntax of the switch statement.

rohit_singh_0-1655470434319.png

Obsoleszenzwahrscheinlichkeit =

var Lieferantenrisiko =
SWITCH(
TRUE(),
Inventory[Anzahl Lieferanten] = 1, 3,
Inventory[Anzahl Lieferanten] > 1 && Inventory[Anzahl Lieferanten] < 4, 2,
Inventory[Anzahl Lieferanten] > 3, 1
)


var Herstellerrisiko =
SWITCH(
TRUE(),
Inventory[Anzahl Hersteller] = 1, 3,
Inventory[Anzahl Hersteller] > 1 && Inventory[Anzahl Hersteller] < 4, 2,
Inventory[Anzahl Hersteller] > 3, 1
)

var EOLRisiko =
SWITCH(
TRUE(),
Inventory[Zeit bis EOL] < 365, 1,
Inventory[Zeit bis EOL] >= 365 && Inventory[Zeit bis EOL] <= 730, 2,
Inventory[Zeit bis EOL] > 730, 3
)

var result =
(2 * Lieferantenrisiko) * Herstellerrisiko * EOLRisiko

Return
result
 

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

Thank you so much Rohit!

Now it works perfectly 🙂

tamerj1
Community Champion
Community Champion

Hi @weberna 
You missed the (   )  after TRUE ( ) in the first variable. Also delete the (  " "  ) from around the numbers. Eg. write 1 not "1"

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.