The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I am trying to calculate the amount of active years for customers.
We have different tables like "documents transaction date", "customer" and "sales values" .
The Tranaction date table is a calender, Customer is all customer information and both are linked to Sales values where are all transactions.
I can see the Active years in a matrix per year.
Cumulative Distinct Count Until this YTD = TOTALYTD(DISTINCTCOUNT([Related Customer]),'SALES VALUES'[Related Date])
But it is not giving me
Customer years active.
A 2
B 1
c 3
Etc.
Solved! Go to Solution.
Hi @Sjon1791 ,
thank you for the interesting question.
You can solve this by adding a calculated column to your customer table.
The formula is the following:
Years active = VAR currentCustomer = CALCULATE(SELECTEDVALUE('CUSTOMERS'[Customer])) VAR lastYearActive = CALCULATE(MAX('SALES VALUE'[Related Date]),'SALES VALUE'[Customer]=currentCustomer) VAR firstYearActive = CALCULATE(MIN('SALES VALUE'[Related Date]),'SALES VALUE'[Customer]=currentCustomer) RETURN YEAR(lastYearActive)- YEAR(firstYearActive)
And here is what it looks like:
Finally, you can also find a Power BI file with an example here.
Let me know if this helps you!
Regards,
LC
Interested in Power BI templates? Check out my blog at www.finance-bi.com
Hi @Sjon1791 ,
thank you for the interesting question.
You can solve this by adding a calculated column to your customer table.
The formula is the following:
Years active = VAR currentCustomer = CALCULATE(SELECTEDVALUE('CUSTOMERS'[Customer])) VAR lastYearActive = CALCULATE(MAX('SALES VALUE'[Related Date]),'SALES VALUE'[Customer]=currentCustomer) VAR firstYearActive = CALCULATE(MIN('SALES VALUE'[Related Date]),'SALES VALUE'[Customer]=currentCustomer) RETURN YEAR(lastYearActive)- YEAR(firstYearActive)
And here is what it looks like:
Finally, you can also find a Power BI file with an example here.
Let me know if this helps you!
Regards,
LC
Interested in Power BI templates? Check out my blog at www.finance-bi.com
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
102 | |
82 | |
62 | |
56 |
User | Count |
---|---|
254 | |
119 | |
115 | |
100 | |
76 |