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
BaldAccountant
Helper III
Helper III

Power Pivot Formula Bogging down Excel

This is a power pivot question, not Power BI

I am trying to determine if I have a favorable or unfavorable variance with a dynamic formula and it is locking up excel.   I am not sure if it is my formula or if I am just trying to do too much in Power Pivot/Excel

 

Here is the first formula I tried :

Test P:=SWITCH(TRUE(),

[Selected good bad]="Good"&&[Test O]>=0,"Good",

[Selected good bad]="Good"&&[Test O]<0,"Bad",

[Selected good bad]="Bad"&&[Test O]<=0,"Good",

[Selected good bad]="Bad"&&[Test O]>0,"Bad",0)

 

Here is  the second one I tried:

Test Q:=SWITCH([Selected good bad],

"Good",IF([Test O]>=0,"Good","Bad"),

"Bad",IF([Test O]<=0,"Good","Bad"),0)

Please let me know if I am doing something wrong in my formulas.  Test O is a formula that calculates the difference between the filtered formula and the average for all doctors.  So then if it is a "Good: Stat, that means that a positive difference from the average would be favorable (i.e. More cases than average.   A "Bad" calculation is where a positive differnce would be unfavorable, such as a higher cost per case.  

Sorry I can't include my file because it contains HIPPA info.

1 ACCEPTED SOLUTION

 

@BaldAccountant , I think it's a problem 
(!_IsGood && _Diff <= 0)

Try, if not can work(Power BI we use not )
(not _IsGood && _Diff <= 0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@BaldAccountant , Try if this can help

 

Test Result :=
VAR _IsGood = [Selected good bad] = "Good"
VAR _Diff   = [Test O]
RETURN
IF(
    (_IsGood  && _Diff >= 0) ||
    (!_IsGood && _Diff <= 0),
    "Good",
    "Bad"
)

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

For some reason if I use a second variable for the "Bad" instead of ! _IsGood then it works.

Test Result:=VAR _IsGood = [Selected good bad] = "Good"

Var isbad = [Selected good bad]="Bad"

VAR _Diff = [Test O]

RETURN

IF(

(_IsGood && _Diff >= 0) ||

(isbad && _Diff <= 0),

"Good",

"Bad"

)

 

I am not sure what to do as far as marking a solution?  I will wait and if you can tell me what I did wrong using your solution I will mark yours as the solution.  I want you to get credit for tellin me to use variables.

I am getting this error

BaldAccountant_0-1764086227383.png

I am not sure why it is showing the extra two ")"  I just copied and pasted in your solution

 

 

@BaldAccountant , I think it's a problem 
(!_IsGood && _Diff <= 0)

Try, if not can work(Power BI we use not )
(not _IsGood && _Diff <= 0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

That worked. Thanks

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.