Forum Discussion

barb_19's avatar
barb_19
Frequent Visitor
3 years ago

Need help with DAX Measure

Hi Community,

 

I need help with a measure that I trying to modify in a model.

 

Transactions table -

IDTypeIsRevenueIsBundleSKUProductIDUnitLineQtyBundleQty
123Net Sales10123A10
456Net Sales11123Bundle02
998Net Sales11214B01
1000Net Sales10567Bundle10
479Net Sales10214Bundle10

 

I am trying to create a single measure (not a calculated column) called InvoicedQty that will go through two filters to calculate the Sum on the Unit Line Qty and Bundle Qty.

 

Here are the two filter conditions which cannot be summed:

Type ='Net Sales' && IsRevenue =1 THEN SUM(UnitLineQty)

Type ='Net Sales' && IsRevenue =1 && IsBundle =1 THEN SUM(BundleQty)

 

5 Replies

  • Arul's avatar
    Arul
    Super User

    barb_19 ,

    try this, if not this is expected please share the screenshot of expected output.

    Sum on the Unit Line Qty and Bundle Qty = 
    VAR _sumOfUnitLineQty = 
    CALCULATE(
        SUM('Table (3)'[UnitLineQty]),'Table (3)'[Type] = "Net Sales",IsRevenue =1)
    VAR _sumOfBundleeQty = 
    CALCULATE(
        SUM('Table (3)'[BundleQty]),'Table (3)'[Type] = "Net Sales",IsRevenue =1,IsBundle =1)
    VAR _output = _sumOfUnitLineQty+_sumOfBundleeQty
    RETURN _output

    Thanks,

    • barb_19's avatar
      barb_19
      Frequent Visitor

      Thanks for sharing the solution. However, adding the two columns is skewing the numbers due to the discrepancy in the data. Is is possible to not add the two columns?

  • Hi,

    can you post the desired achievement (your expected result)?

    • barb_19's avatar
      barb_19
      Frequent Visitor

      Desired Results: A new column that sums respective Qty based on the filter criteria

      IDTypeIsBundleSKUProductIDUnitLineQtyBundleQtyInvoicedQty
      123Net Sales0123A101
      456Net Sales1123Bundle022
      998Net Sales1214B011
      479Net Sales0214Bundle101

       

  • There is no ISREVENUE() column in your data.  Please share a proper dataset and show the expected result.