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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply

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])

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

--try3

Mesurevar =
var Selected_Date = SELECTEDVALUE(DateToChoose[Date])
RETURN
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.

1 REPLY 1
lbendlin
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

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors
Top Kudoed Authors