Thelonious Monk
Thelonious Monk

Reputation: 466

Power BI - how to create measure based on conditions

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?

Upvotes: 0

Views: 779

Answers (1)

Simon Noer Petersen
Simon Noer Petersen

Reputation: 129

  1. Power bi groups the data in a visual automatically.
  2. if they are linked you can make a calculated column in Orders
TimeRemaining =
SUM ( OperationNo[TimeTaken] )

  1. if you want a it in the Operations specifically then:
TimeRemaining =
CALCULATE (
    SUM ( Operations[TimeTaken] ),
    ALLEXCEPT ( Operations, Operations[OrderNo] )
)

NOTE. the first is for a calculated column in Orders table the second one is for the Operations table.

Upvotes: 1

Related Questions