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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
FabiNeed
Helper I
Helper I

Creating a bar chart with special condition

I face the following challenge and am grateful for any help:

I have two different tables from which I want to create a bar chart. In Table 1 there is a Unique ID in the first column and country codes in the second and third column. The countries can be identical, but also different for the same Unique ID:

 

UniqueID Country_1Country_2
1444765|5439351 AFGAIA
2329290|5683159 ALBAFG
1874843|6096713 DZAALB
2149806|5298293 ASMDZA
3248770|6395273 ANDASM
3507469|4342633 AGOALB
3038413|4648776 AIADZA
2809583|4398770 ATAASM
2868538|5369172 ATGAND
2146966|5620333 ARGAND

 

In Table 2, the first column contains a (fancy) category name, followed by several columns, each containing values for a specific country per category:

 

CategoryAFGALBDZAASMANDAGOAIAATAATGARG
Famone1322121111
Omicet1123321211
Pausne1223311313
Bizoad1232122232
Peamul2123321323
Aconat3323323112

 

The objective is, to ...

  • ... check for each Unique ID which country has the higher value in each category (e.g. for "1444765|5439351" and the category "Famone" AIA would has the higher value (2) compared to AFG (1).
  • ... create a bar chart that looks like this (with the correct values, of course):
  •  

Up1.png

I uploaded a PowerBI file with the raw data from the tables: PowerBI file

I am happy for any ideas and solutions.

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @FabiNeed ,

According to your description, I download your pbix. As shown below, each ID corresponds to unique country.

vkalyjmsft_0-1654579531300.png

So you can get "which country has the higher value in each category" or "which Unique ID has the higher value in each category", they are actually the same result. But I'm not sure if that's what you mean by "for each Unique ID which country has the higher value in each category".

If that is the case, put category in the bar chart Axis, country in the Legend and value in Values, get the result.

vkalyjmsft_1-1654580448365.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you @v-yanjiang-msft for this suggestion. Unfortunately, this is not quite what I was looking for. I'll try to make it a little clearer :

 

Let's take the first row from Table 1:

 

UniqueID Country_1Country_2
1444765|5439351 AFGAIA

 

There is a UniqueID with two different countries. For each country, there is a value in Table 2. In this case: 

 

CategoryAFGAIA
Famone11
Omicet11
Pausne11
Bizoad12
Peamul21
Aconat33

 

This reads, for example: For the Category "Bizoad" the value for Country "AFG" is 1 and for Country "AIA" 2. My objective is to automatically choose the higher value for the bar chart visualization. In the visualisation the values (1 to 3) should be taken as the legend. Do you (or of course anyone else) have a solution for this as well? 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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