Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
kk_shp_user
Frequent Visitor

Matrix of LY category vs Curretn Year category

I have sales data in the below format - 50,000 reps with monthly sales data. It has sales category for each month.

 

kk_shp_user_0-1717859383710.png

 

I want to create a matrix visual to show how the reps switched categories between the two years on a month wise basis. Basically the below visual which will show the count of reps.

 

kk_shp_user_1-1717859404186.png

 

How can this be achieved?

3 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

I have solved a similar question in the attached PBI file.

Hope this helps.

Ashish_Mathur_0-1717889142327.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

v-rzhou-msft
Community Support
Community Support

Hi @kk_shp_user ,

 

You may refer to my sample to learn more details.

My Sample:

vrzhoumsft_0-1718010305443.png

Firstly we need to create two unrelated category table for matrix rows and columns.

LY CATEDORY = VALUES('Table'[sales_category])
TY CATEDORY = VALUES('Table'[sales_category])

Also, we need a date table for slicer.

DimDate = ADDCOLUMNS(CALENDARAUTO(),"Year",YEAR([Date]),"Month",MONTH([Date]),"MonthName",FORMAT([Date],"MMMM"),"month_ending",EOMONTH([Date],0))

vrzhoumsft_1-1718010379624.png

Measure:

Measure = 
VAR _CatLY = MAX('LY CATEDORY'[sales_category])
VAR _CatTY = MAX('TY CATEDORY'[sales_category])
VAR _Transform = FILTER(SUMMARIZE('Table',[Rep_id],"LY",CALCULATE(MAX('Table'[sales_category]),FILTER('Table',YEAR('Table'[month_ending]) = 2023)),"TY",CALCULATE(MAX('Table'[sales_category]),FILTER('Table',YEAR('Table'[month_ending]) = 2024))),[LY]<>BLANK() && [TY]<>BLANK())
RETURN
CONCATENATEX(SUMMARIZE(FILTER(_Transform,_CatLY = [LY] && _CatTY = [TY]),[Rep_id]),[Rep_id],",")

Result is as below.

vrzhoumsft_2-1718010420502.png

vrzhoumsft_3-1718010426681.png

 

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.

 

View solution in original post

6 REPLIES 6
v-rzhou-msft
Community Support
Community Support

Hi @kk_shp_user ,

 

You may refer to my sample to learn more details.

My Sample:

vrzhoumsft_0-1718010305443.png

Firstly we need to create two unrelated category table for matrix rows and columns.

LY CATEDORY = VALUES('Table'[sales_category])
TY CATEDORY = VALUES('Table'[sales_category])

Also, we need a date table for slicer.

DimDate = ADDCOLUMNS(CALENDARAUTO(),"Year",YEAR([Date]),"Month",MONTH([Date]),"MonthName",FORMAT([Date],"MMMM"),"month_ending",EOMONTH([Date],0))

vrzhoumsft_1-1718010379624.png

Measure:

Measure = 
VAR _CatLY = MAX('LY CATEDORY'[sales_category])
VAR _CatTY = MAX('TY CATEDORY'[sales_category])
VAR _Transform = FILTER(SUMMARIZE('Table',[Rep_id],"LY",CALCULATE(MAX('Table'[sales_category]),FILTER('Table',YEAR('Table'[month_ending]) = 2023)),"TY",CALCULATE(MAX('Table'[sales_category]),FILTER('Table',YEAR('Table'[month_ending]) = 2024))),[LY]<>BLANK() && [TY]<>BLANK())
RETURN
CONCATENATEX(SUMMARIZE(FILTER(_Transform,_CatLY = [LY] && _CatTY = [TY]),[Rep_id]),[Rep_id],",")

Result is as below.

vrzhoumsft_2-1718010420502.png

vrzhoumsft_3-1718010426681.png

 

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.

 

Thanks!

Ashish_Mathur
Super User
Super User

Hi,

I have solved a similar question in the attached PBI file.

Hope this helps.

Ashish_Mathur_0-1717889142327.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks for your response but unfortunately I cannot download external files.

rajendraongole1
Super User
Super User

Hi @kk_shp_user Can you create the measure below to calculates the count of reps who switched categories between the current year and the previous year for the current month

 

Reps_Switched_Categories =
CALCULATE(
DISTINCTCOUNT('Sales'[RepID]),
FILTER(
ALL('Sales'),
CALCULATE(DISTINCTCOUNT('Sales'[Sales_category]), 'Sales'[Year] = YEAR(TODAY()))
<> CALCULATE(DISTINCTCOUNT('Sales'[Sales_category]), 'Sales'[Year] = YEAR(TODAY()) - 1)
&& 'Sales'[Month] = MONTH(TODAY())
)
)

 

you can change the table name/column names as per your model

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thanks but what if I want to show the counts for those who haven't changes as well. Ex: those who were in Cat 1 LY and CY

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.