Forum Discussion
User input for the start date
- Anonymous9 years ago
Hi thanish,
According to your description, you want to use slicer choose an end date instead of filter data, right?
If it is a case, you can follow below steps:
Data table:
Calendar table: (not related to data table)
DateTable = CALENDAR(MIN(Sheet1[Start Date]),MAX(Sheet1[End Date]))
Measures.
Use to get the select date:
Selected End data =
var currentEnddate=MAX(Sheet1[End Date])
return
if(HASONEVALUE(DateTable[Date]),VALUES(DateTable[Date]),currentEnddate)calculate the data range and the total price:
Total Price =
var unit=MAX(Sheet1[Unit_Price])
var qty=MAX(Sheet1[Quantity])
var startDate= MAX(Sheet1[Start Date])
var endDate= MAX(Sheet1[End Date])
return
CALCULATE(if(AND([Selected End data]<=endDate,[Selected End data]>=startDate), DATEDIFF(startDate,[Selected End data],MONTH),if([Selected End data]<startDate,0,DATEDIFF(startDate,endDate,MONTH))) * unit * qty,ALLSELECTED(Sheet1))Create visuals.
Slicer:
Table visual:
Result:
Comment of formula:
if(AND([Selected End data]<=endDate,[Selected End data]>=startDate), DATEDIFF(startDate,[Selected End data],MONTH),if([Selected End data]<startDate,0,DATEDIFF(startDate,endDate,MONTH)))if “selected date” is between “startdate” and “enddate”, get the date range to calculate. If “selected date” less than “start date”, set date range to 0. If “selected date” greater than “enddate” set the date range to old range.
If above is not help, please feel free to post.
Regards,
Xiaoxin Sheng
Hi thanish,
According to your description, you want to use slicer choose an end date instead of filter data, right?
If it is a case, you can follow below steps:
Data table:
Calendar table: (not related to data table)
DateTable = CALENDAR(MIN(Sheet1[Start Date]),MAX(Sheet1[End Date]))
Measures.
Use to get the select date:
Selected End data =
var currentEnddate=MAX(Sheet1[End Date])
return
if(HASONEVALUE(DateTable[Date]),VALUES(DateTable[Date]),currentEnddate)
calculate the data range and the total price:
Total Price =
var unit=MAX(Sheet1[Unit_Price])
var qty=MAX(Sheet1[Quantity])
var startDate= MAX(Sheet1[Start Date])
var endDate= MAX(Sheet1[End Date])
return
CALCULATE(if(AND([Selected End data]<=endDate,[Selected End data]>=startDate), DATEDIFF(startDate,[Selected End data],MONTH),if([Selected End data]<startDate,0,DATEDIFF(startDate,endDate,MONTH))) * unit * qty,ALLSELECTED(Sheet1))
Create visuals.
Slicer:
Table visual:
Result:
Comment of formula:
if(AND([Selected End data]<=endDate,[Selected End data]>=startDate), DATEDIFF(startDate,[Selected End data],MONTH),if([Selected End data]<startDate,0,DATEDIFF(startDate,endDate,MONTH)))
if “selected date” is between “startdate” and “enddate”, get the date range to calculate. If “selected date” less than “start date”, set date range to 0. If “selected date” greater than “enddate” set the date range to old range.
If above is not help, please feel free to post.
Regards,
Xiaoxin Sheng