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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
dwel0120
Helper III
Helper III

What if Parameter returning specific values

I am creating a what if parameter slider. My goal is to use this slider to only include certain values that have data in that year. For example, if a student has a test score in year 18-19 then they would be included when I select "1" in the what if slicer. If the student does not have a score, then they would be excluded. If a student has a test score for 17-18 and 18-19 then they would be included in the "2" selection of the slicer and so on to four years (if selecting the  4 slicer then they would have data for 15-16 through 18-19 and if they miss a year then they would be excluded). I'm not sure how to build the measure to tie in the what if slicer. 

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @dwel0120 

According to your description and sample data, I can roughly understand your requirement, and I’v also created some test data to make a test, I think you can try my steps:

This is my test data:

vrobertqmsft_0-1624242828553.png

 

  1. Create a calculated column in the main table like this:
Year count = CALCULATE(DISTINCTCOUNT('Table'[Year]),FILTER(ALL('Table'),[StudentID]=EARLIER('Table'[StudentID])))
  1. Create a What-if parameter and add a slicer to the page:

vrobertqmsft_1-1624242828557.png

 

  1. Create a measure:
Flag =

IF(MAX('Table'[Year count])=[Parameter Value],1,0)
  1. Create a table chart and place it and apply a visual filter like this:

vrobertqmsft_2-1624242828563.png

 

And you can get what you want.

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, @dwel0120 

According to your description and sample data, I can roughly understand your requirement, and I’v also created some test data to make a test, I think you can try my steps:

This is my test data:

vrobertqmsft_0-1624242828553.png

 

  1. Create a calculated column in the main table like this:
Year count = CALCULATE(DISTINCTCOUNT('Table'[Year]),FILTER(ALL('Table'),[StudentID]=EARLIER('Table'[StudentID])))
  1. Create a What-if parameter and add a slicer to the page:

vrobertqmsft_1-1624242828557.png

 

  1. Create a measure:
Flag =

IF(MAX('Table'[Year count])=[Parameter Value],1,0)
  1. Create a table chart and place it and apply a visual filter like this:

vrobertqmsft_2-1624242828563.png

 

And you can get what you want.

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@dwel0120 ,

Measure  =

var _1 = distinctcount(Table[year])

Var _2 = countx(filter(values(Table[Student]), _1 = selectedvalue(whatif[parameter])),[Student])

return

_2

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 I'm not sure that will work with my current data set... 

 

dwel0120_0-1623253127642.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.