Forum Discussion
CountRows of Matrix Visualization with values from a Measure
Hello, I have this matrix visualization below, corporate donor name from table 1, year 2017-2020 from table 2, and the values (donor status) as a measure to categorize the donor status.
The ultimate goal is to calculate the number of 'new', 'lapsed', 'recurring', 'lost', 'recovered' (values) for each year to do a YoY analysis. Currently met with difficulty to countrows on measure.
Not sure and
Appreciate your help!
Hi wongzqn,
Please refer to the steps:
1. Create a status table by enter data:
Then create a calculated table:
Donor Status year = CROSSJOIN(VALUES('Status'[Donor Status]),VALUES(_Calendar[Year]))Then you can use the following measure to count values:
Measure = VAR t = SUMMARIZE ( CROSSJOIN ( VALUES ( CombinedData[Donor Name] ), VALUES ( _Calendar[Year] ) ), CombinedData[Donor Name], _Calendar[Year], "status", [Donor Status] ) RETURN COUNTX ( FILTER ( t, [Year] = MAX ( 'Donor Status year'[Year] ) && [status] = MAX ( 'Donor Status year'[Donor Status] ) ), [Donor Name] ) + 0For more details, please refer to pbix file: https://qiuyunus-my.sharepoint.com/personal/pbipro_qiuyunus_onmicrosoft_com/_layouts/15/onedrive.aspx
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
5 Replies
- amitchandakSuper User
wongzqn , The information you have provided is not making the problem clear to me. Can you please explain with an example.
Can you share sample data and sample output in table format?Please refer these three
https://blog.enterprisedna.co/new-vs-existing-customers-advanced-analytics-w-dax/
https://www.sqlbi.com/articles/computing-new-customers-in-dax/https://community.powerbi.com/t5/Desktop/Churn-Rate-lost-Customer/m-p/1173754#M529196
Appreciate your Kudos.- wongzqnFrequent Visitor
Hi amitchandak, thanks for reverting!
Sample data:
Donor Name Donation Value Donation Date DonorA 500 9 Sep 2018 DonorB 1000 8 Dec 2018 DonorA 1000 7 Mar 2019 Sample Output:
Donor Status Year Count New 2017
10 Lost 2017 7 Recurring 2017 9 Recovered 2017 10 Lasped 2017 43 New 2018
15 Lost 2018 12 Recurring 2018 8 Recovered 2018 11 Lasped 2018 45 New 2019
20 Lost 2019 15 Recurring 2019 16 Recovered 2019 15 Lasped 2019 47 The value of 'Donor Status' is a measure where I categorize and label based on date and donation:
2.9 Donor Status =
VAR ThisYearDonations =
CALCULATE(SUM(CombinedData[Donation Cash Value]), DATESYTD(_Calendar[Date]))
VAR LastYearDonations =
CALCULATE(SUM(CombinedData[Donation Cash Value]), PREVIOUSYEAR(_Calendar[Date]))
VAR PriorYearsDonations =
CALCULATE(SUM(CombinedData[Donation Cash Value]),
FILTER(
ALL(_Calendar[Date]),
YEAR(_Calendar[Date]) < YEAR(MAX(_Calendar[Date]))-1
)
)RETURN
IF(AND(ThisYearDonations = 0 && LastYearDonations = 0, PriorYearsDonations > 0), "Lost",
(IF(AND(ThisYearDonations= 0 && LastYearDonations = 0, PriorYearsDonations = 0), "NA",
(IF(AND(ThisYearDonations = 0, LastYearDonations > 0), "Lapsed",
(IF(AND(ThisYearDonations > 0, LastYearDonations > 0), "Recurring",
(IF(AND(ThisYearDonations > 0 && LastYearDonations = 0, PriorYearsDonations > 0), "Recovered",
(IF(AND(ThisYearDonations > 0 && LastYearDonations = 0, PriorYearsDonations = 0), "New", BLANK())))))))))))- v-deddai1-msftCommunity Support
Hi wongzqn,
Please refer to the steps:
1. Create a status table by enter data:
Then create a calculated table:
Donor Status year = CROSSJOIN(VALUES('Status'[Donor Status]),VALUES(_Calendar[Year]))Then you can use the following measure to count values:
Measure = VAR t = SUMMARIZE ( CROSSJOIN ( VALUES ( CombinedData[Donor Name] ), VALUES ( _Calendar[Year] ) ), CombinedData[Donor Name], _Calendar[Year], "status", [Donor Status] ) RETURN COUNTX ( FILTER ( t, [Year] = MAX ( 'Donor Status year'[Year] ) && [status] = MAX ( 'Donor Status year'[Donor Status] ) ), [Donor Name] ) + 0For more details, please refer to pbix file: https://qiuyunus-my.sharepoint.com/personal/pbipro_qiuyunus_onmicrosoft_com/_layouts/15/onedrive.aspx
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
- Greg_DecklerCommunity Champion
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.