Forum Discussion

stieve63's avatar
stieve63
New Member
2 years ago
Solved

Calculate function context issue

Hello,

Think I have a context issue with my calculate function:

Tot sales Qty Fietsen =
CALCULATE([Total Sales Quantity],
Products[Product Group Level 1] = "fietsen",
NOT Products[Product Group Level 2] IN {"compensatie afmontage","kortingen"},
Products[Product Group Level 3] <> "accu"
)
See attachment: why is it counting 286 for a lot of lines where I except the same as the Total Sales Quantity (example row 3) or 'blank' (example row 6 'compensatie afmontage') ?
 

 

What am I doing wrong in the syntax?

  • HI,

    I am not sure if I understood your question correctly, but please try something like below whether it suits your requirement.

     

    Tot sales Qty Fietsen =
    CALCULATE (
        [Total Sales Quantity],
        FILTER (
            Products,
            Products[Product Group Level 1] = "fietsen"
                && NOT ( Products[Product Group Level 2] IN { "compensatie afmontage", "kortingen" } )
                && Products[Product Group Level 3] <> "accu"
        )
    )
    

2 Replies

  • HI,

    I am not sure if I understood your question correctly, but please try something like below whether it suits your requirement.

     

    Tot sales Qty Fietsen =
    CALCULATE (
        [Total Sales Quantity],
        FILTER (
            Products,
            Products[Product Group Level 1] = "fietsen"
                && NOT ( Products[Product Group Level 2] IN { "compensatie afmontage", "kortingen" } )
                && Products[Product Group Level 3] <> "accu"
        )
    )
    
  • Thx a lot Jihwan_Kim 
    How could I overlook the FILTER function, I feel a bit stupid now but still new at PowerBI, learning everyday ğŸ˜‰