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

How to calculate this measure

I have a base table 'Orders' with a column OrderNo, this column is being used in a visual.

 

I have another table 'Operations' with columns: OrderNo, OperationNo, TimeTaken (this is just a numeric column). This table is related to base table with OrderNo. Please note that one OrderNo can have multiple OperationNo.

 

I want to add a column to my visual 'TimeRemaining', which takes all OperationNo (from Operations table) for an OrderNo and sums the TimeTaken column.

 

How can I achieve this?

6 REPLIES 6
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

I made a sample data as follows.

vstephenmsft_0-1634194130228.png

 

Try this measure

 

SUM BY OrderNo =
CALCULATE (
    SUM ( Operations[TimeTaken ] ),
    FILTER ( ALLSELECTED ( Operations ), [OrderNo] = MAX ( 'Operations'[OrderNo] ) )
)

 

13.png

Please check my attachment.

 

 

Best Regards,

Stephen Tao

 

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

Anonymous
Not applicable

Anonymous
Not applicable

Thank you for the reply.

 

I see that this formula and using a SUM(TimeTaken) yields the same result.

 

I will open a new question for this one, as the problem seems to be elsewhere.

amitchandak
Super User
Super User

@Anonymous , hope these tables are joined on the order number.

 

If you are using the duration/time type column, you need to do little bit of work to add that

 

refer if these can help in that

https://radacad.com/calculate-duration-in-days-hours-minutes-and-seconds-dynamically-in-power-bi-using-dax
https://social.technet.microsoft.com/wiki/contents/articles/33644.powerbi-aggregating-durationtime-in-dax.aspx

Anonymous
Not applicable

The TimeTaken column can just be treated as numeric column. Yes, the tables are joined on OrderNo. I have updated the question

@Anonymous , if you need a new column  in Table1

 

sumx(relatedtable(Table2), Table2[Time taken])

 

in case of measure

sum( Table2[Time taken]) 

 

should do

 

refer 4 ways to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

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.