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.
hello, I have one table like this
id customerID salesdate salesamount
001 10001 20200101 200
002 10001 20200101 300
003 10003 20200102 400
004 10003 20200203 1000
.............
I need to create a measure to show the frequency of purchase for customers during a selected period , like this
frequency of purchase=switch( true(), count(customerID)=1, "one time", "more than one time"). but this measure can not work.
please guide me how to create this measure to show the frequency of purchase for each customer
Solved! Go to Solution.
Hi, @Anonymous ;
Try it.
frequency of purchase =
var _count=CALCULATE(COUNT('Table'[customerID]),FILTER(ALLSELECTED('Table'),[customerID]=MAX('Table'[customerID])))
return
IF(_count=1,"one time", "more than one time")
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous ;
Allselected() is to make the result vary according to the selected slicer. max(): [A]=max([A]) is also a method of grouping; here refers to the ID to calculate the count for the group.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous ;
I am so sorry late reply due to account issues; you could create another measure.
count = CALCULATE(DISTINCTCOUNT('Table'[customerID]),FILTER('Table',[frequency of purchase]="one time"))
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous ;
I am so sorry late reply due to account issues; you could create another measure.
count = CALCULATE(DISTINCTCOUNT('Table'[customerID]),FILTER('Table',[frequency of purchase]="one time"))
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous ;
Allselected() is to make the result vary according to the selected slicer. max(): [A]=max([A]) is also a method of grouping; here refers to the ID to calculate the count for the group.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous ;
Try it.
frequency of purchase =
var _count=CALCULATE(COUNT('Table'[customerID]),FILTER(ALLSELECTED('Table'),[customerID]=MAX('Table'[customerID])))
return
IF(_count=1,"one time", "more than one time")
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks a lot! Now I understand it. Could I ask you further about this question? Now I can get the number of purchase frequency for each customer during the selected time period, and then I need to calculate for this time period, how many customers purchased only once, and how many purchased more than once.
also I found if I use a date slicer, the result can not change with slicer.
Thank you a lot!
May I ask you why you use
ALLSELECTED('Table')
but not use only 'Table'. and why you use
[customerID]=MAX('Table'[customerID])
Thanks again!
@Anonymous , refer to my video on segmentation. Use the count measure in place of the sum measure I used. Your Group by /values is customer
Dynamic segmentation -Measure to Dimension conversion: https://youtu.be/gzY40NWJpWQ
Bucket/Segment code
measure
Measure = Count(Table[id])
new Table
bucket = Generateseries(1,100,1)
new Measure
Countx(filter(Values(Table[customerID]), [Measure] = max(bucket[Value])), [customerID])
Buket should be used in visual
else
Sumx(Values(bucket[Value]) ,calculate( Countx(filter(Values(Table[customerID]), [Measure] = max(bucket[Value])), [customerID]) ))
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 |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |