Forum Discussion
Calculating Orders Frequency
- 8 years ago
Hi chernni,
For the two questions, they all based on how to make groups.
1. Frequency of order. Add 'Orders Fre'[Customer] = EARLIER ( 'Orders Fre'[Customer] ) inside the Filter to make the formula be based on Customer group. Then it will get the next date within the same customer group not the next physical row.
Frequency of order = DATEDIFF ( CALCULATE ( MAX ( 'Orders Fre'[Date] ), FILTER ( 'Orders Fre', 'Orders Fre'[Date] < EARLIER ( 'Orders Fre'[Date] ) && 'Orders Fre'[Customer] = EARLIER ( 'Orders Fre'[Customer] ) ) ), 'Orders Fre'[Date], DAY )2. Frequent items. Same issue. In my prior expression I'm using ALLEXCEPT ( 'Orders Fr', 'Orders Fr'[Item.ID] ) to make the formula be based on only Item.ID group. That's why all the same Item.ID got the same percentage. So to resolve your issue, add one more condition in ALLEXCEPT().
Frequent items = DIVIDE ( CALCULATE ( COUNT ( 'Orders Fre'[Item.ID] ), ALLEXCEPT ( 'Orders Fre', 'Orders Fre'[Item.ID], 'Orders Fre'[Customer] ) ), DISTINCTCOUNT ( 'Orders Frequency'[Date] ) )Little tips: the most important point in your requirement is to make groups for your data. And generally in DAX, we can use EARLIER() or ALLEXCEPT() function to ahieve this. EARLIER() is used in calculated column and ALLEXCEPT() can be use in both measure and calculated column.
I think I have shown you the right direction. Please make more effort and try to tune the formula on yourself. :smileyhappy:
Thanks,
Xi Jin.
Hi,
Share the link from where i can download your base data
Sure, check it here: https://app.powerbi.com/groups/me/reports/ad869709-ce18-477a-b876-afc2bd18bbd1/ReportSection
or
Thanks !!!
- Ashish_Mathur8 years agoSuper User
Hi,
Share your raw data - not your PBI report.
- chernni8 years agoFrequent Visitor
Ashish_Mathur please check if you can access here: https://drive.google.com/open?id=1mRNO21ew3QZoDDfol2HVWWjyb-vQ_n_m
Thanks.