Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have a table with quarterly snapshots containing the customer number, end of quarter date, and 'level of engagement' columns. The 'level of engagement' column has a whole number datatype. That column has value of zero or one. Once the 'level of engagement' is set to one, the customer retains that engagement level for the remaining quarters of the year. A value of one indicates the customer is highly engaged. Note that I also have a Date Table related to the Quarterly Date.
My objective is to generate a measure with a count of the 'highly engaged' customers over time without counting the same customer as highly engaged more than once over multiple quarters. That is, if the customer is highly engaged in Q1 then the customer remains highly engaged for each Q2, Q3, and Q4. However, I only want to count this customer as highly engaged once for the entire year and not as highly engaged 4 times. Similarly, if the customer has a zero 'level of engagement' in Q1 and a 1 in Q2, then it should count as 0 in Q1 and should only count once for the rest of the year.
What sort of a DAX pattern would such a measure have?
Solved! Go to Solution.
May not be the most performant and I need to do some testing...but adding this calculated column seems to work when I SUM it up as a measure over time:
HighlyEngagedCount=
VAR
NewHighly = IF('LevelOfEngagement'[Is New Highly Engaged]=TRUE(),1,0)
RETURN
IF(
CALCULATE(COUNTROWS(LevelOfEngagement),
FILTER('LevelOfEngagement','LevelOfEngagement'[Email Address]=EARLIER('LevelOfEngagement'[Email Address])),
FILTER('LevelOfEngagement','LevelOfEngagement'[SnapshotDate]<EARLIER('LevelOfEngagement'[SnapshotDate])),
FILTER('LevelOfEngagement','LevelOfEngagement'[Is New Highly Engaged]=TRUE))
= 0,NewHighly,0)
Hi,
Share the link from where i can download your workbook and show the expected result.
PBIXexampleOfQuarterlySnapshotScenarios This example has my 3 scenarios and includes the calculated column from which I can summarize.
As an inexperienced DAX coder it took me a day to better absorb the Row Context concept and its role with the EARLIER function that I used in this calculation. I realize the column calculation will be iterated a few hundred thousand times in my real world scenario, so please let me know if there is a better performing solution. In any event, my early testing is showing it performs OK enough.
Hi,
Please correct my understandin below:
I am just not clear about your rules. Please take a few cases to show/explain the nuances with reasoning.
Hi,
Thanks for taking the time to consider this use case. Here are my scenarios as depticted by the data in the sample LevelOfEngagement table:
The Page 1 tab of the Report in the sample PBIX shows the expected result. As I said earlier, I ended up creating the calculated column called HighlyEngagedCount that serves the purpose. At this point I am simply curious whether using a calculated column the iterates through the table for each row is the best solution.
Thanks!
Hi,
Thank you for clarifying. Since your question relates to "efficeincy of your working solution", I'd let someone else who is knowledgeable on the issue answer this question. All i know is that a measure is more often that not more efficeicy than a calculated column.
May not be the most performant and I need to do some testing...but adding this calculated column seems to work when I SUM it up as a measure over time:
HighlyEngagedCount=
VAR
NewHighly = IF('LevelOfEngagement'[Is New Highly Engaged]=TRUE(),1,0)
RETURN
IF(
CALCULATE(COUNTROWS(LevelOfEngagement),
FILTER('LevelOfEngagement','LevelOfEngagement'[Email Address]=EARLIER('LevelOfEngagement'[Email Address])),
FILTER('LevelOfEngagement','LevelOfEngagement'[SnapshotDate]<EARLIER('LevelOfEngagement'[SnapshotDate])),
FILTER('LevelOfEngagement','LevelOfEngagement'[Is New Highly Engaged]=TRUE))
= 0,NewHighly,0)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |