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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
BWL
Helper II
Helper II

DAX Formula

Dear all,


At the moment I'm struggling with a complex DAX calculation. 
I have 2 facttables and 2 dimension tables.

tbl_Route
- Date
- Platenumber

- Routecode
- Turnover


tbl_Cost
- Date
- Platenumber
- Cost

dim_Date
- Date
- Period


dim_Trucks
- Platenumber

What I want to do is to sum to create a CALCULATED COLUMN in tbl_Route which contains the cost equally divided by route in period. So for example:  Platenumber 01 had $1000 cost in period 1 and did 150 routes.  1000 / 150 =  6,67 cost per route.

I really don't know how to get it work that the formule filters for the right period.


Can somebody help me and explain me how I can get it done?


Thank's in advance.

Kind regards,

BWL

1 ACCEPTED SOLUTION

Hi @BWL,

 

Actually, a measure would be easy and reasonable. The table tbl_Route doesn't have periods.

Measure = DIVIDE(sum(tbl_Cost[Cost]), COUNT(tbl_Route[Routecode]))

DAX_Formula

 

BTW, please be aware of your privacy.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

Would be easier with example/sample data. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

That being said, perhaps something along the lines of:

 

Column = 
VAR __Cost = CALCULATE(SUM(tbl_Cost[Cost]))
VAR __Routes = COUNTROWS(FILTER(ALL(tbl_Route),[Platenumber] = EARLIER([Platenumber])))
RETURN DIVIDE(__Cost,__Routes,0)

That doesn't factor in Period but too much guesswork without data. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

Thanks for your reply.
I read your blog and I will keep your recommendations in mind.

 

Here you find the sample pbix file :

 

 

Hope this will clearify my question.

 

Kind regards,

BWL

Hi @BWL,

 

Actually, a measure would be easy and reasonable. The table tbl_Route doesn't have periods.

Measure = DIVIDE(sum(tbl_Cost[Cost]), COUNT(tbl_Route[Routecode]))

DAX_Formula

 

BTW, please be aware of your privacy.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-jiascu-msft,

 

Thank you for your reply and privacy concerns!
The whole data set is made up or had it something to do with the dropbox link?


It seems that this simple DIVIDE measurement does the job.

 

Thank you.

Kind regards,

BWL


Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors