Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
cyclones11jmf
Regular Visitor

Using Distinct count combining different filter types

Thanks in advance for your help.

 

I have a measure like such. My ultimate goal is to get a count of distinct customers (cus_no) in a defined time range filtering by (Business Unit), (specific item numbers or product category) -- combined filter

 

Active HBU Customers TEST = CALCULATE(DISTINCTCOUNT('Sales History'[cus_no]),DATESINPERIOD('Sales History'[inv_dt],MAX('DATE TABLE'[Current Date]),-15,MONTH),'Sales History'[business_unit]="HOSP",'Sales History'[item_no]="9000-1000" || 'Sales History'[itm_prod_cat_desc]="Trans-Infant")  that gives me an error of "The expression contains multiple columns, but only a single column can be used in a True/False expression that is used as a table filter expression"

 

Things that have worked:

WORKS

Active HBU Customers TEST = CALCULATE(DISTINCTCOUNT('Sales History'[cus_no]),DATESINPERIOD('Sales History'[inv_dt],MAX('DATE TABLE'[Current Date]),-15,MONTH),'Sales History'[business_unit]="HOSP",'Sales History'[item_no]="9000-1000")

 

However, when I add in the "or" criteria || 'Sales History'[itm_prod_cat_desc]="Trans-Infant") I can't get this filter to work.

 

Does anyone have any ideas? Thanks.

1 REPLY 1
v-jiascu-msft
Employee
Employee

Hi @cyclones11jmf,

 

Try to enclose the conditions with "Filter". 

Active HBU Customers TEST =
CALCULATE (
    DISTINCTCOUNT ( 'Sales History'[cus_no] ),
    DATESINPERIOD (
        'Sales History'[inv_dt],
        MAX ( 'DATE TABLE'[Current Date] ),
        -15,
        MONTH
    ),
    FILTER (
        'Sales History',
        'Sales History'[business_unit] = "HOSP"
            && ( 'Sales History'[item_no] = "9000-1000"
            || 'Sales History'[itm_prod_cat_desc] = "Trans-Infant" )
    )
)

Best Regards,

Dale

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.