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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Distinct count - multiple filters

Dear all!

 

I have a database with multiple columns, which for my issue only 3 are relevant:

- Reference document number

- Date

- Quantities sold.

 

I want to be able to write a DAX formulas that would count the MTD distinct counts of reference document number for which quantities are positive (i.e. it's not a refund).

 

I started with this formula:

Transactions_CY_MTD =
TOTALMTD(calculate(Distinctcount('KE30'[Reference document]),filter(KE30[quantities],">"&0)),'Date Table'[Date])
 
But i get an error message saying that "A single value for column 'quantities' in table 'ke30' cannot be determined. This can happen when a formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
 
Uploading below a simplified version of my datasource - the name of the table in my datamodel of the source is "KE30"
lin_charlotte_0-1636973794036.png

 

thanks in advance for the help!! 

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

Test the below:

Transactions_CY_MTD = 
TOTALMTD (
    CALCULATE (
        DISTINCTCOUNT ( 'KE31'[Reference document] ),
        FILTER ( KE31,[quantities] >0 )
    ),
    'Date Table'[Date]
)

Output result:

vluwangmsft_0-1637303548664.png

 

If not incorrect ,could you pls show me what output you want?

 

 

Best Regards

Lucien

View solution in original post

4 REPLIES 4
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

Test the below:

Transactions_CY_MTD = 
TOTALMTD (
    CALCULATE (
        DISTINCTCOUNT ( 'KE31'[Reference document] ),
        FILTER ( KE31,[quantities] >0 )
    ),
    'Date Table'[Date]
)

Output result:

vluwangmsft_0-1637303548664.png

 

If not incorrect ,could you pls show me what output you want?

 

 

Best Regards

Lucien

Anonymous
Not applicable

Thanks! it worked 🙂

lbendlin
Super User
Super User

You are trying to do a MTD calculation but your sample data only has single values for each month.  That is not sufficient to do MTD calculations.

 

Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. Please show the expected outcome.

Anonymous
Not applicable

Hi Ibendlin,

Thanks for answering, 

My dataset looks like this (I don't seem to be able to add an attachment) - i have daily postings of quantities, by Customer with a reference document. I would like to have the distinct count of reference documents for which the quantity is positive (i.e. not a refund), by period (hence the MTD), so that i can then replicate the MTD Distinct Count to Last Year MTD Distinct Count and Last Last Year Distinct Count. 

 

Thanks for the help!

 

Posting dateCustomerReel SALES QTIES ALL PRODReference document
1/2/2019A1770782093
1/2/2019A1770782028
1/2/2019A1770782087
1/2/2019A1770782062
1/2/2019A1770782025
1/2/2019A1770782026
1/2/2019A1770782063
1/2/2019A1770782022
1/2/2019A1770782047
1/2/2019A1770782046
1/2/2019A1770782023
1/2/2019A1770782045
1/2/2019A1770782027
1/2/2019A-1770782030
1/2/2019A1770782090
1/2/2019A-1770782070
1/2/2019A1770782091
1/2/2019A1770782092
1/2/2019A1770782021
1/2/2019A1770782073
1/2/2019A-1770782057
1/2/2019A1770782064
1/2/2019A-1770782056
1/2/2019A1770782024
1/2/2019A-1770782029
1/2/2019A1770782093
1/2/2019A1770782089
1/2/2019A-1770782069
1/2/2019A1770782093
1/2/2019A1770782088
1/2/2019D1770782016
1/2/2019D1770782059
1/2/2019D1770782018
1/2/2019D1770782059
1/2/2019D1770782015
1/2/2019D1770782017

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.