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
Anonymous
Not applicable

Divide Function with Filter Across Multiple Linked Tables

Hi Everyone, 

Thank you in advance for your time and input, this problem has been plaguing me for a while now. Currently I have the data below (summarized), within two different tables, these tables are linked via the ToolID columns: 

Table 1:

StationIDToolIDMoves
aaa1xxx110
aaa1xxx215
aaa2xxx320

 

Table 2:

ToolIDCost
xxx120
xxx230
xxx340

 

What I have tried doing is using the functions calculate/filter/sum/divide/crossfilter to solve this problem:

I want to sum the tool ID cost by Station ID (for example: StationID "aaa1" Cost = 20 +30 = 50

Then I would use the divide function to have total cost by station family / total move:

Measure Column withhin the matrix visual would show: 

StationIDCost/Move
aaa150/25
aaa240/20 

 

Thank you again! Truly appreciate the support/time. 

1 ACCEPTED SOLUTION
fhill
Resident Rockstar
Resident Rockstar

Assuming ToolID is in a defined relationship between the two tables, I was able to do this Measure below on Table 1.  Hope it helps, Forrest

 

fhill_0-1619711873639.png

 

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




View solution in original post

12 REPLIES 12
fhill
Resident Rockstar
Resident Rockstar

Assuming ToolID is in a defined relationship between the two tables, I was able to do this Measure below on Table 1.  Hope it helps, Forrest

 

fhill_0-1619711873639.png

 

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

Question, how does this function filter to ensure that the cost by ToolID is related to a StationID. How is it linking ToolID's xxx1 and xxx2 to StationID aaa1? Within my real data set there are thousands of costs per ToolID as well as thousands of moves per ToolID which is already linked to StationID within the Data Flow. 

Since I created the Meausre on Table 1 (Station ID, ToolID, and Moves) it reads that table as the limiting factor.  "For every Station ID, we have X ToolIDs.  Now ToolID matches THESE other ToolIDs on this other table, so go get ONLY their mathcing Costs."  Hope this helps... Forrest




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

Okay that is awesome, I was thinking about it further and this makes perfect sense, I overthought this with so many filter functions and declared variables. It will work similarly if I wanted to calculate the CPM for Tool ID as well? So for reference, CPM (xxx1) = 20/10 [using your models values]. Appreciate your support and help here, truly. 

It should.  If your Relationship is a 1 to Many, just build the CPM on whichever table is the "1" so it pulls all the "Many"s from the other table...




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

I'm not sure if this will work sadly then because each ToolID has hundreds of costs associated with it and each tool id has hundreds of moves as well. There is no 1 to many relationship, it is a many to many. 

This does explain why you were having to try the more complicated filters, can you post a few real rows of sample data?  Can a ToolID be on multiple different StationIDs also?

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

I tried posting a more thourough data set and the site pinged me with an error, each toolID is only associated with 1 StationID. The Moves table contains information of a ToolID, StationID and Moves level whereeas the Cost table contains information only relating ToolID to cost. The function I am trying to create will accomplish 2 tasks: 

1) sum total cost from cost table by ToolID / sum total moves by toolID 

2) sum total cost from cost table by ToolID filtered to StationID / sum total move by StationID

 

The Cost and Move tables are linked through the ToolID with a Many to Many and Both cross filter direction. 

 

If you can (if your tables aren't already in complex relationships, try going to Modeling - New Table and using this code to create a true Unique Distinct ToolID table.  It can then be joined 1 to Many to both your existing tables, and your Measures can be palced here to do the math you need...

Unique_ToolID = DISTINCT( UNION( DISTINCT('Table'[ToolID]), DISTINCT('Table (2)'[ToolID])))

 

From here, we may need to understand your tables and data more accuratly to assist furhter, see if you can copy and paste some sample data into a new ticket, so it won't show resolved.  Tag me in your post @fhill  and i'll try to jump in.




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

*I forgot to add that it would probably be two different measures* 

amitchandak
Super User
Super User

@Anonymous , Create a new table 

Dim =summarize(Table, table[StationID],table[ToolID])

 

join with both tables on ToolID

and then analyze with columns of dim

 

new measure = divide(sum(Table2[Cost]),sum(Table[Move]))

Anonymous
Not applicable

I looked into the summarize function, doesnt it work by summarizing columns from within 1 table? I would want to join 2 different tables linked by ToolID. 

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.