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
thampton
Helper III
Helper III

Count & Group by for column with filter across month

i have a table with clientid / salesorder# / orderdate. I would like to have a measure to count how many clients have more than 2 or more orders total. So im thinking this would need to summarize, then do a filter, but not sure how that syntax would work. 

 

For example, below is an example table. I would like a measure to show 1 because only 1 client has had 2 or more orders in this time frame. 

 

I would also like this to cross month. So If i have this connected to my date table, i would like to add in the measure and have it count by month. So if i choose september, it should show 1, if i choose october it would recount, etc..

 

Client           Order ID               Date

a                   1563                    9-2-2020

a                   1234                   9-2-2020

a                   2345                   9-6-2020

b                  5678                    9-7-2020

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

Hi @thampton ,

 

You can create a date table and create one to many relationship between date table and fact table.

Capture.PNG

 

Then you can use the following measure:

 

Measure = var a = SUMMARIZE('Table','Table'[Client ],"orders total",COUNT('Table'[Order ID  ])) return COUNTX(FILTER(a,[orders total]>=2),'Table'[Client ])

 

 

Capture1.PNG

 

For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/Eb6mZMKcBrlHgZGezC...

 

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

 

Best Regards,

Dedmon Dai

 

View solution in original post

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hi @thampton ,

 

You can create a date table and create one to many relationship between date table and fact table.

Capture.PNG

 

Then you can use the following measure:

 

Measure = var a = SUMMARIZE('Table','Table'[Client ],"orders total",COUNT('Table'[Order ID  ])) return COUNTX(FILTER(a,[orders total]>=2),'Table'[Client ])

 

 

Capture1.PNG

 

For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/Eb6mZMKcBrlHgZGezC...

 

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

 

Best Regards,

Dedmon Dai

 

amitchandak
Super User
Super User

@thampton , Try a measure like

sumx(filter(summarize(Table, Table[Client], "_1", count(Table[Order ID])), [_1]>2),[Client])

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.