Forum Discussion

Nicpet0's avatar
Nicpet0
Frequent Visitor
1 year ago
Solved

Calculating unique combination from different tables

Hi Community I am facing an issue in Power Bi with a DAX measure i am trying to create. (See below the pasted code, as it looks currently) I am trying to count each occurence of the unique comb...
  • johnt75's avatar
    1 year ago

    I think your code just needs a little tweak

    Count of Negative Margin =
    VAR Groups =
        SUMMARIZECOLUMNS (
            'Variant'[Variant Item No],
            'Variant'[Variant Code],
            'Sales Person'[Sales Person Name],
            "@gross margin", [Gross Margin 2 %]
        )
    RETURN
        COUNTROWS ( FILTER ( Groups, [@gross margin] < 0 ) )
    

    By including the measure in the SUMMARIZECOLUMNS you will only return combinations of item no, code and sales person which have made sales, rather than all possible combinations which your original code would do. You can then filter that for values below 0.

  • Nicpet0's avatar
    Nicpet0
    1 year ago

    Thanks, that did the trick!