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
MSW
Helper I
Helper I

Multiple Calculations for One Column

Hello,

 

I am looking for a better solution to find the count of one ID from a column associated to an ID in another column. Ideally would count based on the year. So if a customer with an ID has two order numbers that are the same that would be output as 2. 

 

Currently working with a formula like this: 

Calculate(Count('Table'[CustomerID]), Filter('Table'[Order Number] = [Customer ID] = Earlier('Table'[CustomerID). 

This is resulting in the wrong output and not based on year.  The goal is to understand how many orders per year a customer has then eventually how many items are in each order with a certain value. 

 

Any suggestions on how to get this to work more effectively? Thank you

 

Date

Customer ID

Order Number

Calculated Column Read out

  

2020

123

100

2

  

2020

123

100

2

  

2021

123

101

1

  

2019

123

102

1

  

2020

345

200

3

  

2020

345

200

3

  

2020

345

200

3

  

2020

678

300

1

  

2021

678

302

1

  

2019

890

400

2

  

2019

890

400

2

  

2021

890

402

1

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

Hi @MSW ,

 

Do you want count or distinct count?

Is this the expected result?

Column =
COUNTX (
    FILTER (
        'Table',
        'Table'[Date] = EARLIER ( 'Table'[Date] )
            && 'Table'[Customer ID] = EARLIER ( 'Table'[Customer ID] )
    ),
    'Table'[Order Number]
)

vjaywmsft_0-1654678379647.png

 

Best Regards,

Jay

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

View solution in original post

4 REPLIES 4
v-jayw-msft
Community Support
Community Support

Hi @MSW ,

 

Do you want count or distinct count?

Is this the expected result?

Column =
COUNTX (
    FILTER (
        'Table',
        'Table'[Date] = EARLIER ( 'Table'[Date] )
            && 'Table'[Customer ID] = EARLIER ( 'Table'[Customer ID] )
    ),
    'Table'[Order Number]
)

vjaywmsft_0-1654678379647.png

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
MSW
Helper I
Helper I

This works to count the number of Customer IDs in a given year but it does not account for the differnt OrderIDs per customerID per year.

@MSW 

If I correctly understand please use

New Column =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Order Number] ),
    ALLEXCEPT ( 'Table', [Customer ID], 'Table'[Date] )
)
tamerj1
Super User
Super User

Hi @MSW 

you can use

New Column =
CALCULATE (
    COUNTROWS ( 'Table' ),
    ALLEXCEPT ( 'Table', [Customer ID], 'Table'[Date] )
)

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.

Top Solution Authors