I have to create a dashboard which has one single select dropdown of dates and what-if parameter in form of slider, which has values from 0 to 24.
I want to find sum of sales from Table Fact_Sales. Sales should be by month and Year.
Sales should be calculated for the period between Start_Date and End_Date.
Now Start_Date will come from the slider which will be from the below formula:
date(year(HASONEVALUE('Date'[Distinct Delivery Date Key])),month(HASONEVALUE('Date'[Distinct Delivery Date Key]))-Cust_Key[Cust_Key Value],1)
End_Date will come from the Dropdown -->
HASONEVALUE('Date'[Distinct Delivery Date Key])
Cust_Key[Cust_Key Value]
-- >> This is slider value which sliders from 0 to 24 months
The Problem :
While calculating the calculated column from the below formula, I get error as "Cannot convert value 'FALSE' of type Text to type Date."
Is Date Filtered = If(datevalue('Fact Sale'[Delivery Date Key])>=datevalue(date(year(HASONEVALUE('Date'[Distinct Delivery Date Key])),month(HASONEVALUE('Date'[Distinct Delivery Date Key]))-Cust_Key[Cust_Key Value],1)) && datevalue('Fact Sale'[Delivery Date Key]) <= datevalue(HASONEVALUE('Date'[Distinct Delivery Date Key])),1,0)
I have attached error , dropdown and slider screenshots.
Thanks in advance..
Update :
I have updated the DAX calculation from calculated column to measure. The new formula which I made is:
Total Quantity =
var SValue = SELECTEDVALUE('Date'[Distinct Delivery Date Key])
return
CALCULATE(sum('Fact Sale'[Quantity]),FILTER('Fact Sale',[Delivery Date Key] >= date(year(SValue),month(SValue)-Cust_Key[Cust_Key Value],1) &&
[Delivery Date Key] <= date(year(SValue),month(SValue),1)
))