The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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.
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.