Forum Discussion

MMJ369's avatar
MMJ369
Frequent Visitor
7 years ago
Solved

measure with data from 2 tables

I want to create a measure that uses a measure in table one divided by a value in a summarized table.

I can show both values in a table vizualization but I can not get the measure to work.

 

2 Tables:

1. Table 'demand' (via DAX SUMMARIZE per item the demand from another table)

itemdemand
A100
B330
C

60

 

2. Table with Purchase Orders 'POs'

PonritemPoQty
1A50
2B100
3B100
4C20
5A10
6C10

 

In that Po's table I have a maesure:  'TotalPOQty' is a SUM of the POQty filtered on a date range

The result of this measure is:

itemPOQty
A60
B200
C30

 

the Pos table and the demand table are related to each other through a distinct-item table

 

What I require as a result is this:

itemPoQtydemand%demand
A6010060%
B20033061%
C3060

50%

 

Measure '%demand' should be the PoQty divided by the demand

and I would like to have this measure in the TABLE POs

 

How do I create that measure?

Thanks!

  • MMJ369 Please try using "New Table" option

     

    DemandQuantityResult = ADDCOLUMNS(Demand
                                     ,"POQty",LOOKUPVALUE(Quantity[POQty],Quantity[item],Demand[item])
                                     ,"% Demand",ROUND((LOOKUPVALUE(Quantity[POQty],Quantity[item],Demand[item])/Demand[demand])*100,0))

4 Replies

  • PattemManohar's avatar
    PattemManohar
    Icon for Community Champion rankCommunity Champion

    MMJ369 Please try using "New Table" option

     

    DemandQuantityResult = ADDCOLUMNS(Demand
                                     ,"POQty",LOOKUPVALUE(Quantity[POQty],Quantity[item],Demand[item])
                                     ,"% Demand",ROUND((LOOKUPVALUE(Quantity[POQty],Quantity[item],Demand[item])/Demand[demand])*100,0))

    • MMJ369's avatar
      MMJ369
      Frequent Visitor

      Thanks for the suggestion.

       

      I do not have a table with the quantities. The PO quantities are only held in a measure within the PO-table.

      Should I first create a table with the first two columns and then use your dax to add the rest?

       

       

      I really need to be able to use the demand per item in the PO table.

       

      • PattemManohar's avatar
        PattemManohar
        Icon for Community Champion rankCommunity Champion

        MMJ369 Please create an intemediate "Quantity" table by using your "POs" table, grouping on Item and suming up the quantity

  • What does your data model look like? It should work, if you use a table visualization, put an item from your items table in it, and then following measures:

    SUM(POs[PoQty])

    SUM(Table[Demand])

    DIVIDE( SUM(POs[PoQty]), SUM(Table[Demand]) )