Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Issue faced in dynamic cluster assignment to ids on dynamic aggregation of codes used linked to week

I am trying to develop a visual in Power BI which shows the distribution of ID by clusters based on counts of codes applied and I want to do it dynamically based on a week slicer.

 

Let me explain my requirement with some sample data attached in the PowerBI. I have a table(Main_Table) of 3 columns, they are: 'Weeks','id','code_types'. Now when I am counting 'code_types' ,grouping by 'id' only, I am getting 2 columns: 'id' and 'count_of_code_types' , then creating a derived column 'codes_distribution'  from 'count_of_code_types' column by creating segments/groups , like '1 code','2-3 codes','4 codes','5 codes' and 'More than 5 codes'. Now I am creating a clustered bar chart with axis as 'codes_distribution' and in the values as distinct count of 'id', I am getting the desired visual chart.

 

However when I am grouping by 'Weeks','id' and getting 'count_of_code_types' , then the counts of code_types are getting split between the weeks here and thus creating a derived column 'codes_distribution' similarly will have different static segments. Hence now the segments/groups are like '1 code','2-3 codes' only and creating a clustered bar chart with this 'codes_distribution' as axis will create a bar chart with 'codes_distribution' as axis . Hence how can I get the bar chart as before, so that it will create 'codes_distribution' column dynamically based on the week selected by taking sum of code applied across the selected weeks for an ‘id’?

 

I am sharing the link to the power bi desktop file which is having the data and corresponding visuals.https://drive.google.com/drive/u/0/folders/1gsSLyuz0R0swTKkoLPyD8QpxtfqRuRe9 

10 Replies