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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mikelee1701
Helper III
Helper III

How can I move from columns to rows in a chart?

How can I move from columns to rows in a chart?

 

 

I want to duplicate a chart similar to this from Excel:

excel chart.png

But the only thing that I can come close to it using the maxtrix visual:

pbichart.png

How can I move the Year as columns and move the categories (ending in "g") to rows?

 

The columns (ending in "g") are from the same table.

The columns highlighted in yellow are measurements.

The Variance column, is also a measurement derived from the first two columns.

 

 

thank you much!

Mike

1 ACCEPTED SOLUTION

Hi @mikelee1701 ,

 

We can use the unpivot function in Power Query Editor and create a measure to meet your requirement.

 

1. Using unpivot to change the structure. Select date column and unpivot other columns.

 

H1.jpg

 

2. Then we add a year column.

 

H2.jpg

 

3. At last we can create a measure, and create two matrix table, let one table convers another.

 

Variance = 
DIVIDE(
    CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]=2018)),
    CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]=2019)))

 

H3.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

View solution in original post

7 REPLIES 7
v-zhenbw-msft
Community Support
Community Support

Hi @mikelee1701 ,

 

Is your table structure like the first or second?

 

H1.jpg

 

H2.jpg

 

If your table structure like the first screenshot, you can create a measure to get the result.

 

Variance = DIVIDE(SUM('Table'[2018]),SUM('Table'[2019]))

 

H3.jpg

 

If your table structure like the second screenshot, we suggest to create three measures and put them in Values.

 

2018 Measure = CALCULATE(SUM('Table (2)'[value]),FILTER('Table (2)','Table (2)'[Year]=2018))
2019 Measure = CALCULATE(SUM('Table (2)'[value]),FILTER('Table (2)','Table (2)'[Year]=2019))
Variance measure = DIVIDE([2018 Measure],[2019 Measure])

 

H4.jpg

 

Or you can use the following steps to create a table and a measure.

 

1. Create a table like this,

 

Table 2 = CROSSJOIN(VALUES('Table (2)'[OT]),UNION(VALUES('Table (2)'[Year]),{"Variance"}))

 

H5.jpg

 

2. Then we create a matrix table using this table, and create a measure to get the result.

 

Measure = 
var _2018 = CALCULATE(SUM('Table (2)'[value]),FILTER('Table (2)','Table (2)'[OT]=MAX('Table 2'[OT]) && 'Table (2)'[Year]=2018))
var _2019 = CALCULATE(SUM('Table (2)'[value]),FILTER('Table (2)','Table (2)'[OT]=MAX('Table 2'[OT]) && 'Table (2)'[Year]=2019))
return
SWITCH(
    TRUE(),
    MAX('Table 2'[Year])="2018",_2018,
    MAX('Table 2'[Year])="2019",_2019,
    MAX('Table 2'[Year])="Variance",DIVIDE(_2018,_2019)
    )

 

H6.jpg

 

If it doesn’t meet your requirement, could you please provide a mockup sample based on fake data?

It will be helpful if you can show us the exact expected result based on the tables.

 

Please upload your files to OneDrive For Business and share the link here. Please don't contain any Confidential Information or Real data in your reply.

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

Hi @v-zhenbw-msft ,

 

I think I am second after doing prior post:

bpi q_LI.jpg

I am using the following slicers to get one of the measurements (2018):

https://www.sqlbi.com/articles/filtering-and-comparing-different-time-periods-with-power-bi/

 

so I am not sure how that complicates things, but I need a little time to digest this and try it out.  Thank you so much!  I'll be back...

 

Mike

 

Hi @mikelee1701 ,

 

If your table structure likes this, maybe you can refer the following ways.

 

H1.jpg

 

1. Create two tables. One contains 2018 and 2019. Another contains Variance.

 

Table 2 = SUMMARIZE(FILTER('Table','Table'[Column1]="2018"||'Table'[Column1]="2019"),'Table'[OT],'Table'[Column1],'Table'[Column2])

 

H2.jpg

 

Table 3 = SUMMARIZE(FILTER('Table','Table'[Column1]="Variance"),'Table'[OT],'Table'[Column1],'Table'[Column2])

 

H3.jpg

 

2. Then we can create two matrix table. And let one table convers another.

 

H4.jpg

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

Hi @v-zhenbw-msft ,

 

First of all, thank you for your help. 

However, I have tried and I think my data is totally set up different then how your sample is set up.

Here is my raw data:

rawtable.png

 I have data going all the way back from 2/13/2018 to now.  In column "...g", which has a bunch of values for each date.  Column "...ng", with more values and so on... 

 

I have a filter slicer that is comparing the data from a period of time (like 12/2019 vs 12/2018), then showing the percentage difference (variance) between the two periods.

Hope this is enough to explain what I am trying to accomplish.  Let me know if not.

 

Thank you so much!

 

Mike

 

 

Hi @mikelee1701 ,

 

We can use the unpivot function in Power Query Editor and create a measure to meet your requirement.

 

1. Using unpivot to change the structure. Select date column and unpivot other columns.

 

H1.jpg

 

2. Then we add a year column.

 

H2.jpg

 

3. At last we can create a measure, and create two matrix table, let one table convers another.

 

Variance = 
DIVIDE(
    CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]=2018)),
    CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]=2019)))

 

H3.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

@v-zhenbw-msft ,

 

Thank you! thank you!

 

I was pretty deep in a bunch of visuals with my orginal data , I could not do it that way, but I duplicated a new table with your suggestions, and it worked!

I didn't have to do the variance the way you suggested it.  I used a simple measurement , (value/value -1)and put on the same matrix without problems.

Annotation 2020-08-13 112019.png

 

Best,

Mike.

dedelman_clng
Community Champion
Community Champion

HI @mikelee1701 

 

Don't put anything in the Rows for the visual, and select "Show on Rows" under the "Values" format menu.

 

2020-08-05 15_33_15-IT Spend - BPC - Power BI Desktop.png

 

Hope this helps

David

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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