Forum Discussion

amadnei's avatar
amadnei
New Member
2 years ago
Solved

Sales from different table dependant on the promo code

Hi guys,  I am unsure how to proceed DAX wise with my current small project, I'll try to keep it short :  I have a main sales table (t1) with all the sales, with all the generic codes I have a s...
  • Anonymous's avatar
    Anonymous
    2 years ago

    VahidDM  Thanks for your contribution on this thread.

    Hi amadnei ,

    You can follow the steps below to get it, please find the details in the attachment.

    1. Create the relationship between 'All sales' table and 'promotion code' table with the field 'All sales' [[ITEM_NAME]] and 'promotion code' [PROMO_ITEM_NAME]

    2. Create a measure as below to get it:

    SALE_FROM_CODE = 
    VAR _itemname =
        SELECTEDVALUE ( 'All sales'[ITEM_NAME] )
    RETURN
        CALCULATE (
            SUM ( 'All sales'[SALES] ),
            FILTER (
                'All sales',
                'All sales'[ITEM_NAME] = _itemname
                    && 'All sales'[SALE_CODE] IN VALUES ( 'promotion code'[PROMO_CODE] )
            )
        )

    Best Regards