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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
tb92
Frequent Visitor

Date Variable Price

Hello, I have the following data table;

 

IDAdmission DateDischarge DateDurationCurrent Cost
130/01/202302/02/20233 
201/02/202310/02/20239 
331/01/2023 45 

 

(ID 3 Does has not been discharged yet)

 

I would like to calculate current cost based off (Duration * Day Rate) using the following reference table 

 

Start DateEnd DateDay Rate
01/01/202331/01/20235
01/02/202328/02/202310

 

Where Day Rate is variable, based on the Admission and Discharge Date

 

Could someone please help me with the appropriate DAX formula / solution to this problem? 

 

Thanks

1 REPLY 1
amitchandak
Super User
Super User

@tb92 , You need a date table with start date of month and end date of month

 

date = Addcolumns(calendar(date(2020,01,01), date(2021,12,31) ), "Month no" , month([date])
, "Year", year([date])
, "Month Year", format([date],"mmm-yyyy")
, "Month year sort", year([date])*100 + month([date])
, "Qtr Year", format([date],"yyyy-\QQ")
, "Qtr", quarter([date])
, "Month",FORMAT([Date],"mmmm")
, "Month sort", month([DAte])
, "Is Today" ,if([Date]=TODAY(),"Today",[Date]&"")
,"Day of Year" , datediff(date(year([DAte]),1,1), [Date], day)+1
, "Month Type", Switch( True(),
eomonth([Date],0) = eomonth(Today(),-1),"Last Month" ,
eomonth([Date],0)= eomonth(Today(),0),"This Month" ,
Format([Date],"MMM-YYYY") )
,"Year Type" , Switch( True(),
year([Date])= year(Today()),"This Year" ,
year([Date])= year(Today())-1,"Last Year" ,
Format([Date],"YYYY")
)
)

 

then use measures given video or blog for between range

 

Power BI Dax Measure- Allocate data between Range: https://youtu.be/O653vwLTUzM

 

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.