Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hello Everyone,
Can you help me create measure for below?
I need to categorize the values based on support in the last five years:
if the product is supported in the last five years then the category would be "Loyal",
if the product is supported only in current year then "New"
if the product is unsupported in the last five years then "former & non-purchasing"
if the product is supported 3 or 4 out of the last 5 years then "potentially loyal"
if the product is supported 2 or 1 out of the last 5 years but not in the current year then "transient"
sample illustration is below:
Your help will be greatly appreciated!
Solved! Go to Solution.
Hi @JB17 ,
I created some data:
Here are the steps you can follow:
1. Create calculated column.
Flag =
var _yearcurrent=YEAR(TODAY())
var _count=
CALCULATE(DISTINCTCOUNT('Table'[Year]),
FILTER(ALL('Table'),'Table'[Group]=EARLIER('Table'[Group])&&'Table'[support]="yes"&&'Table'[Year]>=_yearcurrent-4&&'Table'[Year]<=_yearcurrent))
return
SWITCH(
TRUE(),
_count=5,"Loyal",
_count>=3&&_count<=4&&
CALCULATE(DISTINCTCOUNT('Table'[Year]),
FILTER(ALL('Table'),'Table'[Group]=EARLIER('Table'[Group])&&'Table'[support]="yes"&&'Table'[Year]=_yearcurrent))=0,"Potentially Loyal",
_count=1&&
CALCULATE(DISTINCTCOUNT('Table'[Year]),
FILTER(ALL('Table'),'Table'[Group]=EARLIER('Table'[Group])&&'Table'[support]="yes"&&'Table'[Year]=_yearcurrent))=1,"New",
_count=BLANK(),"Former&Non-Purchasing",
_count>=1&&_count<=2&&
CALCULATE(DISTINCTCOUNT('Table'[Year]),
FILTER(ALL('Table'),'Table'[Group]=EARLIER('Table'[Group])&&'Table'[support]="yes"&&'Table'[Year]=_yearcurrent))=0,"transient")
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @JB17 ,
I created some data:
Here are the steps you can follow:
1. Create calculated column.
Flag =
var _yearcurrent=YEAR(TODAY())
var _count=
CALCULATE(DISTINCTCOUNT('Table'[Year]),
FILTER(ALL('Table'),'Table'[Group]=EARLIER('Table'[Group])&&'Table'[support]="yes"&&'Table'[Year]>=_yearcurrent-4&&'Table'[Year]<=_yearcurrent))
return
SWITCH(
TRUE(),
_count=5,"Loyal",
_count>=3&&_count<=4&&
CALCULATE(DISTINCTCOUNT('Table'[Year]),
FILTER(ALL('Table'),'Table'[Group]=EARLIER('Table'[Group])&&'Table'[support]="yes"&&'Table'[Year]=_yearcurrent))=0,"Potentially Loyal",
_count=1&&
CALCULATE(DISTINCTCOUNT('Table'[Year]),
FILTER(ALL('Table'),'Table'[Group]=EARLIER('Table'[Group])&&'Table'[support]="yes"&&'Table'[Year]=_yearcurrent))=1,"New",
_count=BLANK(),"Former&Non-Purchasing",
_count>=1&&_count<=2&&
CALCULATE(DISTINCTCOUNT('Table'[Year]),
FILTER(ALL('Table'),'Table'[Group]=EARLIER('Table'[Group])&&'Table'[support]="yes"&&'Table'[Year]=_yearcurrent))=0,"transient")
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Ask questions in Eventhouse and KQL, Eventstream, and Reflex.
User | Count |
---|---|
71 | |
37 | |
21 | |
19 | |
15 |
User | Count |
---|---|
125 | |
34 | |
27 | |
25 | |
24 |