Forum Discussion

o59393's avatar
o59393
Icon for Post Prodigy rankPost Prodigy
6 years ago
Solved

If multiplication from 2 different tables

Hi all

 

How can I get a multiplication from 2 different tables that have in common a column with an IF scenario.

 

The multiplication consists of 2 values (sales and ingredient 1 value) from 2 different tables.

 

The formula (and expected result) I did in excel is the followning:

 

 

The multiplication of these 2 values will depend on date fields. Pretty much if the column I (date)  value is within the columns E and F, then apply the multiplication if not, leavre a zero.

 

I attach the expected result and pbix.

 

https://1drv.ms/u/s!ApgeWwGTKtFdhkHJA5ZPhxb-6AoH?e=FJbbY8

 

Thanks community.

  • Hi, o59393 

     

    I have done some optimizations for the dax. It works in the sample data. But I am not sure if it works in your final pbix file. You may try the following calculated column.

     

    ResultColumn = 
    var _date = 'Sheet1 (2)'[Date]
    var m = 'Sheet1 (2)'[Merge]
    return
    CALCULATE(
        SUM('Formulas'[Value]),
        'Formulas',
        'Formulas'[Merge] = m ,
        _date>=Formulas[Validity Start Date],
        _date<=Formulas[Validity End Date],
        Formulas[Attribute]="Ingredient 1"
    )*'Sheet1 (2)'[Sales]*0.01
    /CALCULATE(
            COUNTROWS('Formulas'),
            'Formulas',
            'Formulas'[Merge] = m ,
            _date>=Formulas[Validity Start Date],
            _date<=Formulas[Validity End Date],
            Formulas[Attribute]="Ingredient 1"
    )

     

     

    Resutl:

     

    Best Regards

    Allan

     

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

14 Replies