Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi team,
I could really use some help. i have a data table similar to that below basically showing Customer ID's and Dates that they placed an Order. I want to create a graph as below that basically shows the sum of the Loyal Customers over a time period. A Loyal Customer is someone who orders more than twice.
So in March we should only have 1 loyal customer (customer A with 3 orders).
In April we should have 2 loyal customers (customer A with a total of 4 orders and customer C with a total of 3 orders).
I have tried the following DAX but it isnt cummulative:
Solved! Go to Solution.
Loyal Customers count =
VAR _currentmonthyear =
MAX ( Dates[End of Month] )
VAR _untilcurrentmonthyeartable =
FILTER ( ALL ( Sales ), Sales[Order Date] <= _currentmonthyear )
VAR _customerscounttable =
GROUPBY (
_untilcurrentmonthyeartable,
Sales[Customer ID],
"@customerscount", SUMX ( CURRENTGROUP (), 1 )
)
VAR _loyalcustomerstable =
FILTER ( _customerscounttable, [@customerscount] > 2 )
RETURN
COUNTROWS ( _loyalcustomerstable )
Loyal Customers count =
VAR _currentmonthyear =
MAX ( Dates[End of Month] )
VAR _untilcurrentmonthyeartable =
FILTER ( ALL ( Sales ), Sales[Order Date] <= _currentmonthyear )
VAR _customerscounttable =
GROUPBY (
_untilcurrentmonthyeartable,
Sales[Customer ID],
"@customerscount", SUMX ( CURRENTGROUP (), 1 )
)
VAR _loyalcustomerstable =
FILTER ( _customerscounttable, [@customerscount] > 2 )
RETURN
COUNTROWS ( _loyalcustomerstable )
Hi @Jihwan_Kim
Thank you for your help in the first problem.
I was hoping you could help me adjust the Loyalty value. So instead of a fixed 2 orders making a loyal customer, i want to put a slicer on the page where the user can decide what constitutes a loyal customer, and then the slicer value can be used in the measure you described above.
So if the user chooses 7, then a loyal customer will be anyone with more than 7 orders.
The slicer should range from 1 to the maximum amount of orders by 1 single customer.
I created a table to summarize the Sales tables by ID and Count of ID (which is the number or orders).
Is this possible?
Thanks in advance
Sammy_Ned
Hi,
In my opinion, I think you can create a slicer by using "New Parameter" UI.
Then, in the measure, instead of 2, replace it with "selectedvalue( newparameter slicer value)".
Sorry that I could not find the sample pbix file, so I only could write like the above.
Thanks.
Works perfectly.
Thanks Jihwan_Kim
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
10 | |
6 |