Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
T_JF2022
Frequent Visitor

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.

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

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.

 

Jihwan_Kim_1-1668774090555.png

 

Jihwan_Kim_0-1668774066083.png

 

 

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]
                )
        )
    )
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
v-jianboli-msft
Community Support
Community Support

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.

Jihwan_Kim
Super User
Super User

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.

 

Jihwan_Kim_1-1668774090555.png

 

Jihwan_Kim_0-1668774066083.png

 

 

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]
                )
        )
    )
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors