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

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

Reply
rockbredo9
Regular Visitor

Count customers who made at least three order in the last three Months

Hi All, 

 

I have three tables , one for sales , one for calendar and one for customers. I have one date for all  days because are the sales for a mall center. Orders are the numbers of receipts /sales that a customer made. wth two years of datas.

 

Sales :

DateCustomerKeyOrders
01/01/202204010021
02/01/202204010031
03/01/202204010041
04/01/202204010051
05/01/202204010061
06/01/202204010071
07/01/202204010082
08/01/202204010091
09/01/202204010102
10/01/202204010051
.......

 

Calendar : 

datemonthyear
01/01/202212022
02/01/202212022
03/01/202212022
04/01/202212022
05/01/202212022
06/01/202212022
07/01/202212022
08/01/202212022
09/01/202212022

 

I want to know the number of customers who made at least three ( >=3 orders) in the last three months.

I previously calculated a measure for the total of Orders

I tried with this :

 

VAR CustomerswithOrders =
CALCULATETABLE (
ADDCOLUMNS (
VALUES ( Sales[CustomerKey] ),
"@NumberofSales", [TotalOrders]
),
ALLEXCEPT ( Sales, Customer ),DATESINPERIOD (Calendar[Date];MAX(Calendar[Date];-3;MONTHS)))

VAR CustomerswithThreeOrders =
FILTER(CustomerswithOrders ; "@NumberofSales" >=3)
VAR Result
COUNTROWS(CustomerswithThreeOrders)
RETURN
Result

 

The problem is in filtering the time period i think. There is no error when creating the measure. But when I add it to a visual I get the error:  'A table of multiple values was supplied when a single value was expected'

 

Thanks, 

 

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @rockbredo9 

 

You can try the following methods.
Sample data:

vzhangti_0-1670577999679.png

Measure:

Count order = 
CALCULATE (
    SUM ( 'Table'[Order] ),
    FILTER (
        ALL ( 'Table' ),
        [Date] <= TODAY ()
            && [Date] >= TODAY () - 90
            && [Customer ID] = SELECTEDVALUE ( 'Table'[Customer ID] )
    )
)

vzhangti_1-1670578087600.png

Count Customer = CALCULATE(DISTINCTCOUNT('Table'[Customer ID]),FILTER(ALL('Table'),[Count order]>=3))

vzhangti_2-1670578122661.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

View solution in original post

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @rockbredo9 

 

You can try the following methods.
Sample data:

vzhangti_0-1670577999679.png

Measure:

Count order = 
CALCULATE (
    SUM ( 'Table'[Order] ),
    FILTER (
        ALL ( 'Table' ),
        [Date] <= TODAY ()
            && [Date] >= TODAY () - 90
            && [Customer ID] = SELECTEDVALUE ( 'Table'[Customer ID] )
    )
)

vzhangti_1-1670578087600.png

Count Customer = CALCULATE(DISTINCTCOUNT('Table'[Customer ID]),FILTER(ALL('Table'),[Count order]>=3))

vzhangti_2-1670578122661.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

FreemanZ
Super User
Super User

try like:

VAR CustomerswithOrders =
CALCULATETABLE (
ADDCOLUMNS (
VALUES ( Sales[CustomerKey] ),
"@NumberofSales", [TotalOrders]
),
ALLEXCEPT ( Sales, Customer ),DATESINPERIOD (Calendar[Date];MAX(Calendar[Date];-3;MONTH)))
 
VAR CustomerswithThreeOrders =
FILTER(CustomerswithOrders ; [@NumberofSales]>=3)
VAR Result
COUNTROWS(CustomerswithThreeOrders)
RETURN
Result

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.