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.
Hi All,
I want to add a column in my sales table , which indicates if customer exist LAST YEAR then 1 else 0.
Sales table is connect to Date Table.
Thanks a lot.
Solved! Go to Solution.
Hi, @Anonymous
Based on your description, I created data to reproduce your scenario.The pbix file is attached in the end.
Table:
You may create a calculated column or a measure as below.
Calculated column:
Flag Column =
var _count =
COUNTROWS(
FILTER(
ALL('Table'),
[Customer]=EARLIER('Table'[Customer])&&
YEAR([Date])=YEAR(TODAY())-1
)
)
return
IF(
ISBLANK(_count),
0,
1
)
Measure:
Flag Measure =
var _count =
COUNTROWS(
FILTER(
ALL('Table'),
[Customer]=SELECTEDVALUE('Table'[Customer])&&
YEAR([Date])=YEAR(TODAY())-1
)
)
return
IF(
ISBLANK(_count),
0,
1
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous
Based on your description, I created data to reproduce your scenario.The pbix file is attached in the end.
Table:
You may create a calculated column or a measure as below.
Calculated column:
Flag Column =
var _count =
COUNTROWS(
FILTER(
ALL('Table'),
[Customer]=EARLIER('Table'[Customer])&&
YEAR([Date])=YEAR(TODAY())-1
)
)
return
IF(
ISBLANK(_count),
0,
1
)
Measure:
Flag Measure =
var _count =
COUNTROWS(
FILTER(
ALL('Table'),
[Customer]=SELECTEDVALUE('Table'[Customer])&&
YEAR([Date])=YEAR(TODAY())-1
)
)
return
IF(
ISBLANK(_count),
0,
1
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Typically you should write a measure for this - not a calculated column formula.
@@Ashish_Mathu Can you share some relevant article. I am trying to do the following
Hi,
Please share some data to work with.
@Anonymous , for the new customer, you can say the one who did not come last year and same this year. With a date table
YTD = calculate([Sales],datesytd('Date'[Date]))
LYTD = calculate([Sales],DATESyTD(DATEADD('Date'[Date],-1,MONTH)))
Lost Customer This Month = Sumx(VALUES(Customer[Customer Id]),if(ISBLANK([YTD]) && not(ISBLANK([LYTD])) , 1,BLANK()))
New Customer This Month = sumx(VALUES(Customer[Customer Id]), if(ISBLANK([LYTD]) && not(ISBLANK([YTD])) ,1,BLANK()))
Retained Customer This Month = if(not(ISBLANK([YTD])) && not(ISBLANK([LYTD])) , 1,BLANK())
Check this blog. This based on MTD. You have to use Datesytd
@Anonymous , Try the column, one of the two should work
if(isblank(countx(filter(table, [customer] = earlier([customer]) && year([customer]) = year(earlier([customer]))-1),[customer])),0,1)
if(isblank(countx(filter(table, [customer] = earlier([customer]) && year([customer]) = year(earlier([customer]))-1),earlier([customer]))),0,1)
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 |
---|---|
107 | |
105 | |
88 | |
74 | |
66 |
User | Count |
---|---|
126 | |
111 | |
100 | |
83 | |
71 |