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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
luisClive
Helper III
Helper III

Excel to Power Bi two axis and grand total help

Hi All,

 

I have the excel below, i want to replicate on Power Bi

 

luisClive_0-1604469288440.png

 

Data Set is below

 

 FY21FY20FY19
 UAEMENationalsUAEMENationalsUAEMENationals
Assurance3915584015412471705
Consulting39846449853981 
Deals82431434511422
TLS6252133134190
Total9228819111317251013127

 

after pivoting and unpivoting for Bi, i managed to get just one axis

I need two axis and grand total

 

LOSME -UAE -NationalsSortHeadcountFY
AssuranceME1155FY21
AssuranceUAE239FY21
AssuranceNationals38FY21
ConsultingME184FY21
ConsultingUAE239FY21
ConsultingNationals36FY21
DealsME124FY21
DealsUAE28FY21
DealsNationals33FY21

 

Power Bi.PNG

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@luisClive 

 

Here is one way of doing this (I'll attach the sample PBIX file to the reply for you).

First the result:

result.JPG

 

This involves creating a disconnected table to use as the legend including the "total" for each category in the axis.

The process involves:

1) Create a new table using the LOS values and adding a row for "Total" (I created it using the "Enter Data" function in the ribbon):

Legend calc.JPG

2) Create a FY table with unique values by referencing a new query to the source table (to ensure that the periods update automatically) and pivot the columns

FY calc.JPG

3) Append both these tables and unpivot the FY columns. The end result is:

Legend Table.JPG

 

4) Load into the model and do not create a relationship

Model.JPG

 

5) Create the relevant measures:

 

 

Headcount sum = SUM('Table'[Headcount])
TREATAS LOS = CALCULATE([Headcount sum], TREATAS(VALUES('Legend Table'[LOS]), 'Table'[LOS]), TREATAS(VALUES('Legend Table'[FY]), 'Table'[FY]))
Total by LOS = CALCULATE([Headcount sum], TREATAS(VALUES('Legend Table'[FY]), 'Table'[FY]))

 

 

6) Now create the measure you will use in the actual visual:

 

 

Chart measure = IF(SELECTEDVALUE('Legend Table'[LOS]) = "Total", 
                    [Total by LOS], 
                        [TREATAS LOS])

 

 

 

7) and build the visual using the Legend Table field "Legend LOS" as the legend:

Visual.JPG

 

😎 finally format the X-axis to your liking.

 

Attached is the sample PBIX

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

10 REPLIES 10
PaulDBrown
Community Champion
Community Champion

@luisClive 

It takes time to get out of the "Excel" mindset...!

Let us know if you get stuck anywhere





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown 

 

Hi Paul

 

would you be kind enough to recheck this solution, which I use a lot

 

after all the new updates to PBI, once i remove items from Axis, Legend and Values well and then try to add the same back,

i cannot achieve below hierarchy any more

 

Either (ME, national....) or (FY...) shows up on X axis.

Both dont show up together

 

luisClive_1-1614778359213.png

 

 

@luisClive 

Sorry I am not following you... Can you post an image of what you are getting?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

@luisClive 

 

Here is one way of doing this (I'll attach the sample PBIX file to the reply for you).

First the result:

result.JPG

 

This involves creating a disconnected table to use as the legend including the "total" for each category in the axis.

The process involves:

1) Create a new table using the LOS values and adding a row for "Total" (I created it using the "Enter Data" function in the ribbon):

Legend calc.JPG

2) Create a FY table with unique values by referencing a new query to the source table (to ensure that the periods update automatically) and pivot the columns

FY calc.JPG

3) Append both these tables and unpivot the FY columns. The end result is:

Legend Table.JPG

 

4) Load into the model and do not create a relationship

Model.JPG

 

5) Create the relevant measures:

 

 

Headcount sum = SUM('Table'[Headcount])
TREATAS LOS = CALCULATE([Headcount sum], TREATAS(VALUES('Legend Table'[LOS]), 'Table'[LOS]), TREATAS(VALUES('Legend Table'[FY]), 'Table'[FY]))
Total by LOS = CALCULATE([Headcount sum], TREATAS(VALUES('Legend Table'[FY]), 'Table'[FY]))

 

 

6) Now create the measure you will use in the actual visual:

 

 

Chart measure = IF(SELECTEDVALUE('Legend Table'[LOS]) = "Total", 
                    [Total by LOS], 
                        [TREATAS LOS])

 

 

 

7) and build the visual using the Legend Table field "Legend LOS" as the legend:

Visual.JPG

 

😎 finally format the X-axis to your liking.

 

Attached is the sample PBIX

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown 

 

OMG, this is some serious wizardry. Appreciate it a lot.

 

Never though something so simple on excel could be so involving.

 

 

 

luisClive
Helper III
Helper III

@PaulDBrown 

 

Could you guide me?

@luisClive , FY as Axis and LOS as legend in clustered column visual

@amitchandak 

 

Doing exactly that, i got the second BI visual i posted

 

However i want my final solution to be like the excel chart i posted ( first Visual)

thanks @amitchandak 

 

I was able to achieve matrix table visual im looking for by unpivoting, but I could do a hybrid/two axis chart like excel

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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