The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I want to create NBTO (New Business Turn Over) report in Power BI. Can you please suggest any template or advise any measures that can handle this requirement.
A customer is a new customer until 12 months since it started and after 12 months it falls in existing customer bucket
My requirement = Total sale of New customer (As per the start date) v/s Prior Year (Same Period)
Solved! Go to Solution.
Hi, @gauravnarchal
If you want to calculate by a selected date, you may create a Calendar table. The pbix file is attached in the end.
Then you may create measures as below.
lost customer sales =
var tab =
ADDCOLUMNS(
'Table',
"Flag1",
IF(
OR(
DATEDIFF([Start Date],SELECTEDVALUE('Calendar'[Date]),MONTH)>6,
DATEDIFF([Start Date],SELECTEDVALUE('Calendar'[Date]),MONTH)=6&&DAY([Start Date])<DAY(SELECTEDVALUE('Calendar'[Date]))
),
1,0
)
)
return
IF(
HASONEVALUE('Calendar'[Date]),
SUMX(
FILTER(
tab,
[Flag1]=1
),
[Sales]
)
)
New customer Sales =
var tab =
ADDCOLUMNS(
'Table',
"Flag1",
IF(
DATEDIFF([Start Date],SELECTEDVALUE('Calendar'[Date]),DAY)<=365,
1,0
)
)
return
IF(
HASONEVALUE('Calendar'[Date]),
SUMX(
FILTER(
tab,
[Flag1]=1
),
[Sales]
)
)
New customer sales last year =
var _date = SELECTEDVALUE('Calendar'[Date])
var tab =
ADDCOLUMNS(
'Table',
"Flag2",
IF(
DATEDIFF([Start Date],DATE(YEAR(_date)-1,MONTH(_date),DAY(_date)),DAY)<=365,
1,0
)
)
return
IF(
HASONEVALUE('Calendar'[Date]),
SUMX(
FILTER(
tab,
[Flag2]=1
),
[Sales]
)
)
Result =
var _date = SELECTEDVALUE('Calendar'[Date])
var tab =
ADDCOLUMNS(
'Table',
"Flag1",
IF(
DATEDIFF([Start Date],_date,DAY)<=365,
1,0
),
"Flag2",
IF(
DATEDIFF([Start Date],DATE(YEAR(_date)-1,MONTH(_date),DAY(_date)),DAY)<=365,
1,0
)
)
return
IF(
HASONEVALUE('Calendar'[Date]),
DIVIDE(
SUMX(
FILTER(
tab,
[Flag1]=1
),
[Sales]
),
SUMX(
FILTER(
tab,
[Flag2]=1
),
[Sales]
)
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @gauravnarchal
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create measures as below.
New customer Sales =
var tab =
ADDCOLUMNS(
'Table',
"Flag1",
IF(
DATEDIFF([Start Date],TODAY(),DAY)<=365,
1,0
)
)
return
SUMX(
FILTER(
tab,
[Flag1]=1
),
[Sales]
)
New customer sales last year =
var tab =
ADDCOLUMNS(
'Table',
"Flag2",
IF(
DATEDIFF([Start Date],DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY())),DAY)<=365,
1,0
)
)
return
SUMX(
FILTER(
tab,
[Flag2]=1
),
[Sales]
)
Result =
var tab =
ADDCOLUMNS(
'Table',
"Flag1",
IF(
DATEDIFF([Start Date],TODAY(),DAY)<=365,
1,0
),
"Flag2",
IF(
DATEDIFF([Start Date],TODAY()-365,DAY)<=365,
1,0
)
)
return
DIVIDE(
SUMX(
FILTER(
tab,
[Flag1]=1
),
[Sales]
),
SUMX(
FILTER(
tab,
[Flag2]=1
),
[Sales]
)
)
Today is 7/20/2020. Here is the result:
Best Regard
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for your response
If you see the below table
Further
Many thanks for your help
Here is the PBIX link -
Do you think above is achievable in Power BI?
Hi, @gauravnarchal
If you want to calculate by a selected date, you may create a Calendar table. The pbix file is attached in the end.
Then you may create measures as below.
lost customer sales =
var tab =
ADDCOLUMNS(
'Table',
"Flag1",
IF(
OR(
DATEDIFF([Start Date],SELECTEDVALUE('Calendar'[Date]),MONTH)>6,
DATEDIFF([Start Date],SELECTEDVALUE('Calendar'[Date]),MONTH)=6&&DAY([Start Date])<DAY(SELECTEDVALUE('Calendar'[Date]))
),
1,0
)
)
return
IF(
HASONEVALUE('Calendar'[Date]),
SUMX(
FILTER(
tab,
[Flag1]=1
),
[Sales]
)
)
New customer Sales =
var tab =
ADDCOLUMNS(
'Table',
"Flag1",
IF(
DATEDIFF([Start Date],SELECTEDVALUE('Calendar'[Date]),DAY)<=365,
1,0
)
)
return
IF(
HASONEVALUE('Calendar'[Date]),
SUMX(
FILTER(
tab,
[Flag1]=1
),
[Sales]
)
)
New customer sales last year =
var _date = SELECTEDVALUE('Calendar'[Date])
var tab =
ADDCOLUMNS(
'Table',
"Flag2",
IF(
DATEDIFF([Start Date],DATE(YEAR(_date)-1,MONTH(_date),DAY(_date)),DAY)<=365,
1,0
)
)
return
IF(
HASONEVALUE('Calendar'[Date]),
SUMX(
FILTER(
tab,
[Flag2]=1
),
[Sales]
)
)
Result =
var _date = SELECTEDVALUE('Calendar'[Date])
var tab =
ADDCOLUMNS(
'Table',
"Flag1",
IF(
DATEDIFF([Start Date],_date,DAY)<=365,
1,0
),
"Flag2",
IF(
DATEDIFF([Start Date],DATE(YEAR(_date)-1,MONTH(_date),DAY(_date)),DAY)<=365,
1,0
)
)
return
IF(
HASONEVALUE('Calendar'[Date]),
DIVIDE(
SUMX(
FILTER(
tab,
[Flag1]=1
),
[Sales]
),
SUMX(
FILTER(
tab,
[Flag2]=1
),
[Sales]
)
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @gauravnarchal
If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.
Best Regards
Allan
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
User | Count |
---|---|
77 | |
76 | |
36 | |
31 | |
29 |
User | Count |
---|---|
93 | |
79 | |
57 | |
48 | |
48 |