Home Forums Power Pivot CALCULATE – More than 1 filter criteria on the same column

This topic contains 1 reply, has 2 voices, and was last updated by  tomallan 7 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5425

    porter444
    Participant
    • Started: 10
    • Replies: 24
    • Total: 34

    Is there an easier way?

    Return Order Count:=CALCULATE([Order Count],FILTER(‘counter sales data’,’counter sales data'[Order Type]=”CO”))+CALCULATE([Order Count],FILTER(‘counter sales data’,’counter sales data'[Order Type]=”CR”))

    #5430

    tomallan
    Keymaster
    • Started: 0
    • Replies: 417
    • Total: 417

    Yes, there are at least three ways to accomplish your objective:

    1. Use the OR() function

    Return Order Count :=
    CALCULATE (
        [Order Count],
        FILTER (
            'counter sales data',
            OR (
                'counter sales data'[Order Type] = "CO",
                'counter sales data'[Order Type] = "CR"
            )
        )
    )

    2. Use the “logical or” operator (||)

    Return Order Count :=
    CALCULATE (
        [Order Count],
        FILTER (
            'counter sales data',
            'counter sales data'[Order Type] = "CO"
                || 'counter sales data'[Order Type] = "CR"
        )
    )

    3. Use portable formulas (a Rob Collie term). This solution consist of three measures and, if the [CO Count] and/or the [CR Count] could be used in multiple measures, is the preferred solution.

    Return Order Count:= [CO Count] + [CR Count]

    CO Count:= CALCULATE([Order Count],FILTER(‘counter sales data’,’counter sales data'[Order Type]=”CO”))

    CR Count := CALCULATE([Order Count],FILTER(‘counter sales data’,’counter sales data'[Order Type]=”CR”))

    Tom

Viewing 2 posts - 1 through 2 (of 2 total)

The forum ‘Power Pivot’ is closed to new topics and replies.