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
daniel_epc
New Member

How to Use a What If Date Parameter

Hi All,

 

Maybe it is a silly question, but I am not able to use a What If Date parameter in a DAX Measure, what I need is to calculate the days between the date parameter and another date field.

 

daniel_epc_1-1674847223948.png

The parameter shows up correctly if I put it directly on the table, but when I try to access its value via DAX it retrieves the Minimum Date of the parameter range, the function SELECTEDVALUE doesn't retrieve any value.

 

Thanks in advance for your help,

 

Daniel

 

3 REPLIES 3
daniel_epc
New Member

Thanks @amitchandak, but it is still not working, the parameter and the dax measure have the same code but the last one doesn't evaluate as desired.

 

Parametro Fecha Value = MINX(ALLSELECTED('Parametro Fecha'[Parametro Fecha]),'Parametro Fecha'[Parametro Fecha])
 
DiasEnInventario = MINX(ALLSELECTED('Parametro Fecha'[Parametro Fecha]),'Parametro Fecha'[Parametro Fecha])
 

daniel_epc_0-1674929864920.png

 

Can you help me to understand what am I missing?

amitchandak
Super User
Super User

@daniel_epc , I am assuming the date parameter table is not joined to another table

 

You can get min/ max date like this 

 

//Date1 is an independent Date table and Date is Joined
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = minx(allselected(Date1),Date1[Date])
return

Averagex(Table, Datediff(Table[Date], _max, Day)

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

Thanks @amitchandak , but I still couldn't get it to work, the parameter and the dax measure have the same code but the last one doesn't evaluate as desired.

 

Parametro Fecha Value = MINX(ALLSELECTED('Parametro Fecha'[Parametro Fecha]),'Parametro Fecha'[Parametro Fecha])
 
DiasEnInventario = MINX(ALLSELECTED('Parametro Fecha'[Parametro Fecha]),'Parametro Fecha'[Parametro Fecha])
 
The date parameter is not joined to any table, should it be?
 
daniel_epc_0-1675014531676.png

 

Thanks in advance,

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.