Forum Discussion

tvanover's avatar
tvanover
Helper II
5 years ago
Solved

create calculated field based on calculation between two fields from different tables (many-to-one)

Hi,

 

I have a report in which I consolidate information from 2 tables:

table A with orderlines

table B with delivery lines

 

there's a many-to-1 relationship between the delivery lines table and the orderlines table. (1 orderline can be fulfilled in several delivery runs).

 

So in my end result, I have this output:

 

OrderArticleOrdererd qtyDelivered qty
1053100012012
105326059330
10533600611
10342302411
103426053B55
103426053R55

 

Ordered qty is the result of 1 record in table A

Delivered qty is the result of an aggregation in table B. it contains the sum of one or more delivery line records that are linked to one orderline record.

 

That's what I managed to figure out myself.

 

But, I need to exclude the rows from the visual, where Ordered qty = Deliverd qty. Because I only want to see information about incomplete orders.

 

I first tried to create a measure to calculate the difference (which worked) , but then I found out that I cannot hide rows based on a measure.

So I think I need to create a calculated column.

 

But I can't find the correct syntax to calculate "ordered qty - delivered qty", because they come from 2 different tables.

 

Can someone explain what is the best way for me to hide these rows?

 

Thanks,

Tom

3 Replies

  • @amitchangak

    Hi, I've found the correct syntax for my calculated field:

     

    Missing = calculate(sum(SalesOrderLines[Aantal Gevraagd]) - calculate(sum(GoodsDeliveryLines[Aantal geleverd])))

     

    So now I've gotten to this point:

    I have both a missing column defined as a measure, and a missing calculated field, because I want to test what works, and what doesn't: 

     

    Order

    Article

    Ordered qty

    Delivered qty

    Missing (measure)

    Missing (calculated field)

    1075

    10015

    2

    2

    0

    0

    1075

    29019

    105

     

     

    105

    1075

    30030

    21

    21

    0

    0

    1075

    36001

    1

    1

    0

    0

    1071

    26132

    60

    60

    0

    0

    1071

    29008

    10

    4

    6

    6

     

    Now I only want to keep the second (105 missing) and the sixth (6 missing) record.

    I've tried a add a filter on the visual, with either the measure or the calculated field, but all that happens is a spinning cursor in the top left of the visual and nothing happens.

     

    So I have not a clue on how to proceed, to eliminated the records with 0 missing...

    • V-lianl-msft's avatar
      V-lianl-msft
      Community Support

      Hi tvanover ,

       

      Based on your description, you can apply the calculated columns or measure you created to the visual level filter in this table visual, and set the condition to not equal to 0.

       

       

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