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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
cmeu
Advocate III
Advocate III

Use treatas in calculate that references default what-if parameter value

I created a what-if parameter called 'Default Target'[Default Target] that ranges from 0.8 to 0.99 in 0.01 increments. The what if parameter also built a measure for me called [Default Target Value] which is meant to return the selectedvalue of the parameter, or its default value:

Default Target Value = SELECTEDVALUE('Default Target'[Default Target], 0.94)

I want to prescribe certain [Default Targets] to load into a table, so I built them to use TREATAS to filter the table:

86_perc = CALCULATE( [MyFancyMeasure], TREATAS({{0.86}},'Default Target'[Default Target]) )

but this didn't give me the expected result (I was expecting it to use 86% as default target, not 94%).

Instead, it returns all rows based on the <alternateResult> of the selectedvalue measure:

cmeu_1-1652203765844.png

 


Why is [CAR_86] not aligning with the actual selectedvalue of the what-if parameter slicer, and also not aligning to the filtered value from the TREATAS function? How can I effectively pass a constant to [MyFancyMeasure] so I don't have to rewrite the entire measure for each constant I want to present?

Edit: I also tried to filter the default target table in the calculate like this but it does the same thing:

CAR_86 = CALCULATE( [Default Target Value], FILTER(ALL('Default Target'),[Default Target]=0.86) )

 

1 ACCEPTED SOLUTION

@amitchandak Thanks for responding.

 

In this case I actually found the solution. The problem has to do with the level of precision in the numbers returned from the GENERATESERIES function which produces the What-If inputs. 0.86 wasn't actually present in the column:

TREATAS( {0.86} , 'Default Target'[Default Target] )  

doesn't work, however:

TREATAS({0.8600000000000002}, 'Default Target'[Default Target] ) 
works perfectly.
 
I tried to specify the increment value should use CURRENCY type, but that didn't help me avoid this issue with numerical precision. This did not help things:
Default Target = GENERATESERIES(CURRENCY(0.6), 1.0, CURRENCY(0.001))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@cmeu , The measure where you do need .94 as default use this ?

Take it a var and pass it.

SELECTEDVALUE('Default Target'[Default Target], 0.86)

 

If you want to remove a selected value, then why do you need whatif, you can filter on static value.

 

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

@amitchandak Thanks for responding.

 

In this case I actually found the solution. The problem has to do with the level of precision in the numbers returned from the GENERATESERIES function which produces the What-If inputs. 0.86 wasn't actually present in the column:

TREATAS( {0.86} , 'Default Target'[Default Target] )  

doesn't work, however:

TREATAS({0.8600000000000002}, 'Default Target'[Default Target] ) 
works perfectly.
 
I tried to specify the increment value should use CURRENCY type, but that didn't help me avoid this issue with numerical precision. This did not help things:
Default Target = GENERATESERIES(CURRENCY(0.6), 1.0, CURRENCY(0.001))

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.