Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Dax

Hi, I have a card and a table visual where I want to show the correct sales value. Have been stucked for few days. Hope someone can show me the solution for this...

 

For the card,

if I filter BU = BU1, I should get 42 for the sales value,

if I filter Brand = A, I should get 30,

if I filter Brand = C, I should get 30,

if I filter BU = BU1 and Brand = A, I want to get 30

 

Currently I have a problem because in the Brand filter, I will only show Brand A, B, C, D. So in order to get the correct value for the brand (e.g. Brand C), I need to check the [Group]. If the [Group] is the same, I need to sum it up.

 

For the table,

I want to show 30, 12, 30, blank for Brand A, B, C, D respectively.

 

Sample data

BUBrandData TypeGroupActualSales
BU1Brand: J01RedJ01 5
BU1Brand: J01 AARedJ01 10
BU1Brand: J01 ABRedJ01 15
BU1Brand: J01 CCRedJ0110 
BU1Brand ABlueJ0110 
BU1Brand: R06RedR06 2
BU1Brand: R06 AARedR06 4
BU1Brand: R06 ABRedR06 6
BU1Brand: R06 CCRedR0615 
BU1Brand BBlueR0620 
BU1Brand CBlueJ012 
BU1Brand DBlueJ089 

 

Thanks,

Bee Kee

 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

    First, you can create a calculated column to get only Brand A, B,C and D. Then create a measure to get the sum of sales. You can find all details in the attachment.

    Nbrand = IF(IFERROR(SEARCH(":",'Sales'[Brand]),0)=0,'Sales'[Brand],BLANK())
    Total sales = 
    VAR _selBrand=SELECTEDVALUE('Sales'[Nbrand])
    VAR _group=CALCULATE(MAX('Sales'[Group]),FILTER('Sales','Sales'[Brand]=_selBrand))
    RETURN
        CALCULATE(SUM('Sales'[Sales]),FILTER(ALL('Sales'),'Sales'[Group]=_group))

    Best Regards
    Community Support Team _ Rena Ruan
    If this post helps, then please consider Accept it as the solution to help the other members find it more.

3 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Paul, I'm not sure how I can attach my excel file so I created a table within the post.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

        First, you can create a calculated column to get only Brand A, B,C and D. Then create a measure to get the sum of sales. You can find all details in the attachment.

        Nbrand = IF(IFERROR(SEARCH(":",'Sales'[Brand]),0)=0,'Sales'[Brand],BLANK())
        Total sales = 
        VAR _selBrand=SELECTEDVALUE('Sales'[Nbrand])
        VAR _group=CALCULATE(MAX('Sales'[Group]),FILTER('Sales','Sales'[Brand]=_selBrand))
        RETURN
            CALCULATE(SUM('Sales'[Sales]),FILTER(ALL('Sales'),'Sales'[Group]=_group))

        Best Regards
        Community Support Team _ Rena Ruan
        If this post helps, then please consider Accept it as the solution to help the other members find it more.