cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jayprekk
New Member

I would like to show customer purchasing pattern from month to month.

Actual Table:

User IDProductMonth Year
100AJan-22
100AFeb-22
100BMar-22
100AApr-22
101BJan-22
101BFeb-22
101CMar-22
102AJan-22
102CFeb-22
102BMar-22
102C

Apr-22

 

I would like to show the product movement from month to month indicating the number of users:

 

 (No of users)Product A to A(No of users)Product A to B(No of users)Product A to C
From January 2022 to February 2022201
From February 2022 to March 2022010

 

Appreciate your support

1 ACCEPTED SOLUTION
FreemanZ
Community Champion
Community Champion

hi @Jayprekk 

not sure if i fully get you, as the expected result seems inconsistent with the dataset.

Anyway, you may try the following:

1) get a date column in your table, like:

FreemanZ_0-1684739815235.png

2) plot a table visual with the [Month Year] column and three measures like:

AtoA = 
VAR _list = 
CALCULATETABLE(
    VALUES(data[User ID]),
    data[Product]="A"
)
VAR _listpre =
CALCULATETABLE(
    VALUES(data[User ID]),
    ALL(data[Month Year]),
    data[Product]="A",
    data[Date]=EDATE(MAX(data[Date]), -1)
)
VAR result =
COUNTROWS(INTERSECT(_list, _listpre))+0
RETURN result
AtoB = 
VAR _list = 
CALCULATETABLE(
    VALUES(data[User ID]),
    data[Product]="B"
)
VAR _listpre =
CALCULATETABLE(
    VALUES(data[User ID]),
    ALL(data[Month Year]),
    data[Product]="A",
    data[Date]=EDATE(MAX(data[Date]), -1)
)
VAR result =
COUNTROWS(INTERSECT(_list, _listpre))+0
RETURN result
AtoC = 
VAR _list = 
CALCULATETABLE(
    VALUES(data[User ID]),
    data[Product]="C"
)
VAR _listpre =
CALCULATETABLE(
    VALUES(data[User ID]),
    ALL(data[Month Year]),
    data[Product]="A",
    data[Date]=EDATE(MAX(data[Date]), -1)
)
VAR result =
COUNTROWS(INTERSECT(_list, _listpre))+0
RETURN result

it worked like:

FreemanZ_2-1684740566591.png

note: only user id 100 is using product A in Jan and Feb. 

View solution in original post

2 REPLIES 2
Jayprekk
New Member

Thank you. Its working as I wanted it to :). Appreciate it!

FreemanZ
Community Champion
Community Champion

hi @Jayprekk 

not sure if i fully get you, as the expected result seems inconsistent with the dataset.

Anyway, you may try the following:

1) get a date column in your table, like:

FreemanZ_0-1684739815235.png

2) plot a table visual with the [Month Year] column and three measures like:

AtoA = 
VAR _list = 
CALCULATETABLE(
    VALUES(data[User ID]),
    data[Product]="A"
)
VAR _listpre =
CALCULATETABLE(
    VALUES(data[User ID]),
    ALL(data[Month Year]),
    data[Product]="A",
    data[Date]=EDATE(MAX(data[Date]), -1)
)
VAR result =
COUNTROWS(INTERSECT(_list, _listpre))+0
RETURN result
AtoB = 
VAR _list = 
CALCULATETABLE(
    VALUES(data[User ID]),
    data[Product]="B"
)
VAR _listpre =
CALCULATETABLE(
    VALUES(data[User ID]),
    ALL(data[Month Year]),
    data[Product]="A",
    data[Date]=EDATE(MAX(data[Date]), -1)
)
VAR result =
COUNTROWS(INTERSECT(_list, _listpre))+0
RETURN result
AtoC = 
VAR _list = 
CALCULATETABLE(
    VALUES(data[User ID]),
    data[Product]="C"
)
VAR _listpre =
CALCULATETABLE(
    VALUES(data[User ID]),
    ALL(data[Month Year]),
    data[Product]="A",
    data[Date]=EDATE(MAX(data[Date]), -1)
)
VAR result =
COUNTROWS(INTERSECT(_list, _listpre))+0
RETURN result

it worked like:

FreemanZ_2-1684740566591.png

note: only user id 100 is using product A in Jan and Feb. 

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Top Solution Authors
Top Kudoed Authors