Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Frequent Visitor

retrieve the value entered/chosen by a user for calculations

In Power BI, I want to give the possibility to the user to enter a date. after much research, the solution I found is to allow the user to choose and not to enter a date. Then I want to retrieve the chosen value in a variable and do the following calculation: For each value in column var2, run var2-datechoose and convert the result to days. the results should be stored in a variable which I will use to build a graph.

The problem is despite all my attempts, nothing worked.

Find below my code:

-- try1

Mesurevar= IF(ISBLANK('Table'[var1]), DATEDIFF('Table'[var2],SELECTEDVALUE(DateToChoose[Date], 1), DAY), BLANK())

Selected Date = SELECTEDVALUE(DateToChoose[Date])

Mesurevar= IF(ISBLANK('Table'[var1]), DATEDIFF('Table'[var2], DATEVALUE([Selected Date]), DAY), BLANK())


Mesurevar =
var Selected_Date = SELECTEDVALUE(DateToChoose[Date])
IF(ISBLANK('Table'[var1]), ('Table'[var2] - DATEVALUE(Selected_Date)), BLANK())


I bound the Date variable from the DateToChoose table to the var2 variable from the Table table.

I would appreciate any help.

Super User
Super User

the results should be stored in a variable which I will use to build a graph.

That's not something you can do in Power BI.  Either you create a static calculated column or table, or you create a (dynamic) measure.   Variables can be used during the creation of either but they cannot be "stored" anywhere.

Helpful resources

PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors