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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pvn
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
3 REPLIES 3
tamerj1
Super User
Super User

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

pvn
Frequent Visitor

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

pvn_1-1675052553983.png

 

 

other having value:

pvn_2-1675052580722.png

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

 

amitchandak
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: https://youtu.be/O653vwLTUzM
https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

 

Power BI: HR Analytics - Employees as on Date : https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors