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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
NMiller
Frequent Visitor

Calculations with What If Parameters

Pretty new to PowerBI and DAX. 

I currently have a calculated column that is calculating time to depth using assumed run speeds for the vertical section and lateral section of a well. The depths and lengths are 2 columns in my table. A team member requested that they be able to adjust the assumed speeds to see time savings by running in faster. 
I discovered what if parameters, which is exactly what I want, however columns evaluate at load time, not run-time. 

So, my question is, is there a way to convert a fairly simple calculation into a measure so I can make this happen?

 

Time_To_Depth = (depth/runSpeedA + length/runSpeedB)/60

1 ACCEPTED SOLUTION

Time_To_Depth  as measure = 
var d = SUM(depth)
var l = SUM(Length)
var mycal = DIVIDE(d, [What if parameter for speed a], 0) + DIVIDE(l, [What if parameter for speed b], 0)
return  DIVIDE(myCal, 60, 0)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

Time_To_Depth  as measure = 
var d = SUM(depth)
var speedA = SUM(runSpeedA)
var l = SUM(Length)
var speedB = SUM(runSpeedB)
var mycal = DIVIDE(d, runSpeedA, 0) + DIVIDE(l, runSpeedB, 0)
return  DIVIDE(myCal, [what if parameter name], 0)

try above, add it it as a measure.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Forgot to mention that runspeed a and b would be the what if parameters. So I've got this in and its giving me pretty different results compared to my calculated colum with static values for the run speeds.

Time_To_Depth  as measure = 
var d = SUM(depth)
var l = SUM(Length)
var mycal = DIVIDE(d, [What if parameter for speed a], 0) + DIVIDE(l, [What if parameter for speed b], 0)
return  DIVIDE(myCal, 60, 0)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Ok. Continuing on further, I am taking this theoretical value, and comparing it to an actual run time. Then trying to convert it to a percent off of the theoretical.  

 

Design Time Variance =
var tvd =averagea('Perf Data'[AVERAGE TVD])
var md = averagea('Perf Data'[Average MD])
var design = (divide(tvd,'Run In Speed - Vertical'[Run In Speed - Vertical Value],0)+DIVIDE(md-tvd,'Run In Speed - Lateral'[Run In Speed - Lateral Value],0)+DIVIDE(md,'Run Out Speed'[Run Out Speed Value]))/60
var actual = AVERAGE('Perf Data'[Wireline Duration])
var difference = actual-design
var percentage = DIVIDE(difference,design,0)
return percentage

 

When I return the difference var, the values match my calculated columns, but the percentages don't match. Any ideas why?

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.