Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

DAX Formula

Good Day.
I need help in creating a formula like a value based on the selected start and end date.
Like this but it is not calculating properly .Thanks in advance

Loading Cost SelectedDate =
var _start= if(MIN('Date'[Date])>=SELECTEDVALUE(BudgetAnnualCost[StartDate]),MIN('Date'[Date]),SELECTEDVALUE(BudgetAnnualCost[StartDate]))
var _end = if(MAX('Date'[Date])<=SELECTEDVALUE(BudgetAnnualCost[EndDate]),MAX('Date'[Date]),SELECTEDVALUE(BudgetAnnualCost[EndDate]))
var _diff = if(_start<_end,DATEDIFF(_start,_end,DAY)+1,0)

Var CST = _diff*SELECTEDVALUE(Project[Daily Loading])

Return CST
Super User
Super User

Hi @pvn 
How does your visual look like? Is there a relationship between the two tables?

Frequent Visitor

Hi @amitchandak  i have one table containing star and end date:




other having value:


so i need to calculate this value on the basis of that start and end date.
thank you


Super User
Super User

@pvn ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.


I think these can help

Between Dates - Dates between
Measure way
Power BI Dax Measure- Allocate data between Range:


Power BI: HR Analytics - Employees as on Date :

!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!

Helpful resources

May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors
Top Kudoed Authors