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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
jeanseb
Frequent Visitor

calculated column for frequency of dates

Hello, I am new on this platform and I need help concerning Power BI!

 

I have a table named Orders, which indicate, for each order, the user name and the date of the order. On the table Users, I would like to create a calculated column named "frequency of orders" which would calculate the frequency of orders for each user.

for example, user3 has made 2 orders, at 7 days of difference, so the frequency should be equal to 7.

Could you help me for that ?

Thanks a lot,

 

image_for_forum.jpg

1 ACCEPTED SOLUTION
jeanseb
Frequent Visitor

Thanks you so much for your help!

 

In fact with your formula for "frequency of orders", the results for my file is always 0... I have created columns "first date" and "last date" and "frequency bis" and now it works well! 

Thanks you again!!!

first date = 
CALCULATE(
    FIRSTDATE ( Orders[created_at] );
    FILTER(Orders ; Orders[user_name] = Users[user_name])
)
last date = CALCULATE( LASTDATE( Orders[created_at] ); FILTER(Orders ; Orders[user_name] = Users[user_name]) )
frequency bis = DIVIDE ( DATEDIFF ( Users[first date]; Users[last date]; DAY ); Users[number of orders] - 1; 0 )

 

image_for_forum_b.jpg

View solution in original post

3 REPLIES 3
Jbmolina93
Frequent Visitor

Why does your solution minus 1 from the number of orders?

Sean
Community Champion
Community Champion

2 Calculated COLUMNS

 

number of orders =
CALCULATE (
    COUNTROWS ( Orders ),
    FILTER ( Orders, Orders[user_name] = Users[user_name] )
)

frequency of orders =
DIVIDE (
    DATEDIFF (
        FIRSTDATE ( Orders[created_at] ),
        LASTDATE ( Orders[created_at] ),
        DAY
    ),
    Users[number of orders] - 1,
    0
)

and the result

 

CC for frequency of dates.png

 

Hope this helps! Smiley Happy

jeanseb
Frequent Visitor

Thanks you so much for your help!

 

In fact with your formula for "frequency of orders", the results for my file is always 0... I have created columns "first date" and "last date" and "frequency bis" and now it works well! 

Thanks you again!!!

first date = 
CALCULATE(
    FIRSTDATE ( Orders[created_at] );
    FILTER(Orders ; Orders[user_name] = Users[user_name])
)
last date = CALCULATE( LASTDATE( Orders[created_at] ); FILTER(Orders ; Orders[user_name] = Users[user_name]) )
frequency bis = DIVIDE ( DATEDIFF ( Users[first date]; Users[last date]; DAY ); Users[number of orders] - 1; 0 )

 

image_for_forum_b.jpg

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors