Forum Discussion
Anonymous
4 years agoNot applicable
summary stats
I have database of customers and their sales history. I am comparing the current year sales to the previous year sales the data would look like this. customer name 2020 sales ...
Anonymous
4 years agoNot applicable
Hi Anonymous ,
You can create a Type table first then create a measure to count the number of customer in each type.
Type =
DATATABLE(
"Type", STRING,{
{"New"},
{"Increase +200%"},
{"Increase 150 - 199%"},
{"Increase 0 - 149%"},
{"Decrease"},
{"Lost"}
}
)
Measure:
Measure =
VAR _ADD =
ADDCOLUMNS('Type',"COUNT",
SWITCH('Type'[Type],
"New",CALCULATE(COUNT('Table'[customer name]),'Table'[Increase/Decrease $] = "New"),
"Lost",CALCULATE(COUNT('Table'[customer name]),'Table'[Increase/Decrease $] = "Lost"),
"Decrease",CALCULATE(COUNT('Table'[customer name]),'Table'[Increase/Decrease %] < 0),
"Increase 0 - 149%",CALCULATE(COUNT('Table'[customer name]),FILTER('Table','Table'[Increase/Decrease %]<>BLANK()&&'Table'[Increase/Decrease %] >= 0&&'Table'[Increase/Decrease %]<=1.49)),
"Increase 150 - 199%",CALCULATE(COUNT('Table'[customer name]),FILTER('Table','Table'[Increase/Decrease %] >= 1.5&&'Table'[Increase/Decrease %]<=1.99)),
CALCULATE(COUNT('Table'[customer name]),FILTER('Table','Table'[Increase/Decrease %] >= 2))
)
)
RETURN
SUMX(_ADD,[COUNT])
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.