Forum Discussion

T_JF2022's avatar
T_JF2022
Frequent Visitor
3 years ago
Solved

DAX Condition multiply

Hello, I have the problem to build a measure in which I multiply by a factor when a condition is met.

 

For Example - Fact Table

NameAmountDate
Adidas10030.10.2022
Nike10030.10.2022
Adidas10030.10.2021
Amazon10030.10.2022

 

Factor Table (Dim)

NameBonusYear

Adidas

2,4%2021
Adidas3%2022
Amazon3,7%2022
Nike1,2%2022

 

 

Thus, I would like to build a measure that correctly calculates the total bonus. Important here, for each customer and each year (when the product was sold) there is a different bonus.
With a deep dive on individual customers, the correct bonus should also be displayed.

I am just lost and don't know where to start, let alone how a measure should look like, since the information of the customer name is available in a column, and a measure can't pull any text information from a column like if I want to start with an if calculation.

 

Thanks for any input.

 

  • Hi,

    I am not sure how your datamodel looks like, but please check the below pictures and the attached pbix file whether it suits your requirement.

     

     

     

     

    Total bonus: = 
    SUMX (
        DISTINCT ( 'Name'[Name] ),
        CALCULATE (
            SUMX (
                'Fact',
                'Fact'[Amount]
                    * MAXX (
                        FILTER (
                            Bonus,
                            Bonus[Name] = RELATED ( 'Name'[Name] )
                                && Bonus[Year] = YEAR ( EARLIER ( 'Fact'[Date] ) )
                        ),
                        Bonus[Bonus]
                    )
            )
        )
    )

     

2 Replies

  • Hi,

    I am not sure how your datamodel looks like, but please check the below pictures and the attached pbix file whether it suits your requirement.

     

     

     

     

    Total bonus: = 
    SUMX (
        DISTINCT ( 'Name'[Name] ),
        CALCULATE (
            SUMX (
                'Fact',
                'Fact'[Amount]
                    * MAXX (
                        FILTER (
                            Bonus,
                            Bonus[Name] = RELATED ( 'Name'[Name] )
                                && Bonus[Year] = YEAR ( EARLIER ( 'Fact'[Date] ) )
                        ),
                        Bonus[Bonus]
                    )
            )
        )
    )

     

  • Hi T_JF2022 ,

     

    Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

     

    Refer to:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

     

    Best Regards,

    Jianbo Li

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