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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
rack201
Frequent Visitor

DAX to calculate value based on start/end date, daily price and rate

I'm trying to build a column that calculates the $ value of multi day 'loading' event based on a daily price and event load rate. 

 

Something like this:

 

calculate the sum of ( date_n price per tonne*daily qty )  where n = load start date ... load end date

 

rack201_0-1644449975028.png

 

Can't get it to work.. any suggestions?

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@rack201 , In case you need a new column

 

New column = [Daily Qunatity] * datediff([start],[end],day)

 


https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

 

 

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your questions correctly, but please try below.

If the data model has the index column in the Load Table, a calculated column might seems more simple than the below.

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Load value CC =
VAR currentstart = Load[Start]
VAR currentend = Load[End]
VAR currentquantity = Load[Daily quantity]
VAR datestable =
CALENDARAUTO ()
VAR Load_datestable =
GENERATE (
FILTER (
Load,
Load[Start] = currentstart
&& Load[End] = currentend
&& Load[Daily quantity] = currentquantity
),
FILTER ( datestable, [Date] >= Load[Start] && [Date] <= Load[End] )
)
VAR Load_datestable_price =
ADDCOLUMNS (
Load_datestable,
"@price", LOOKUPVALUE ( 'Price'[Price per tonne], 'Price'[Date], [Date] )
)
RETURN
SUMX ( Load_datestable_price, Load[Daily quantity] * [@price] )
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @rack201 

do want this in a calculated column or you want visualize it in a matrix/pivot table? Are you using Power Bi or Excel Power Pivot?

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your questions correctly, but please try below.

If the data model has the index column in the Load Table, a calculated column might seems more simple than the below.

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Load value CC =
VAR currentstart = Load[Start]
VAR currentend = Load[End]
VAR currentquantity = Load[Daily quantity]
VAR datestable =
CALENDARAUTO ()
VAR Load_datestable =
GENERATE (
FILTER (
Load,
Load[Start] = currentstart
&& Load[End] = currentend
&& Load[Daily quantity] = currentquantity
),
FILTER ( datestable, [Date] >= Load[Start] && [Date] <= Load[End] )
)
VAR Load_datestable_price =
ADDCOLUMNS (
Load_datestable,
"@price", LOOKUPVALUE ( 'Price'[Price per tonne], 'Price'[Date], [Date] )
)
RETURN
SUMX ( Load_datestable_price, Load[Daily quantity] * [@price] )
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Fantastic- this got me to a working solution - thank you!

amitchandak
Super User
Super User

@rack201 , In case you need a new column

 

New column = [Daily Qunatity] * datediff([start],[end],day)

 


https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

 

 

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.