Forum Discussion
Single BAR Graph for Comparing Previous Year each months V/s Current Year Each Months
Hi Team
I want to create a bar chart were i have do comparison Previous Year Months Vs Current Year months in same Bar graph, able to create two separate graphs as below,
But unable to create a single Graph
Any suggestion?
Thanks,
Hari
19 Replies
- Musadev
Resolver III
Hi harirao
You can add both scenarios in a single visual by adding both measures to a stacked column chart.
Add the Date variable in the X-Axiz and 2 measures in the Y-Axis and you will get the results as shown below.Dax Measure for the Last year's sales and this year's Sales are here. map and link it to your data. Thanks
Sales Amount = SUMX ( Sales, Sales[Quantity] * Sales[Net Price] )Sales Amt Last Year = CALCULATE( Sales[Sales Amount], SAMEPERIODLASTYEAR(Sales[Order Date]) )Good luck for the learning and if it helps mark it as a Solution for your Query. Thanks
- Musadev
Resolver III
wait let me add your data to my data set. and I will update it, you can use the same records, so no worries
If you can share the sum of values DAX i will transform it for last year as well(If measure is used) else only sum of amount on the visual then i will use static values - Musadev
Resolver III
Hi harirao
Please check the following steps. I have used dummy data, for the first year your data will be blank. and after one year you can compare the bars/values.
I have added additional SID column to add up all the rows and get the value for the month.I created a measure to sum the value. here is the DAX code
Sum of Values = SUMX(TBL1, TBL1[Value] )After that, I checked the data in a visual and it is coming as you have shown.
Now i have added another Measure to get the amount of Value for the month of last year.
Sum of Values LY = CALCULATE( [Sum of Values], SAMEPERIODLASTYEAR(TBL1[Month]) )i have added a stacked column Chart to the report pane. and also check the data in the table view below as well.
If you are still have issues then share the PBIX file with masked data and i will validate it. Thanks
- harirao
Post Prodigy
Hi Musadev
I have just uploaded sample pbix file, pls find the below link to access
https://drive.google.com/file/d/1lDc2W7vN0chh7n3xevJHDcqQJ2FwLJyM/view?usp=sharing
Regards,
Hari- Musadev
Resolver III
harirao
I have performed multiple transformations to your sheet.
1- Split the text date into Month (Mmm) and Year (yyyy) and then concatenate them into a new column Month Year.2- The above steps for both tables
3- Change the relationships to the new columns Month Year
4- Add 2 measures, one for this year total value and one for last year. (check Key Measures table)
5- check the tables and the chart for more details.
Here is PBIX file.
https://drive.google.com/file/d/1EPkxiucQzPiWlfsTiljK_9upLQRhbYUY/view?usp=sharing- harirao
Post Prodigy
Hi Musadev
Thank you so much for providing Solution which is giving correct result.
However after creating Clustered Column Chart noticed that Previous Year Month & Current Year Months are not next to each other.
If i try to arrange Nov-22 is coming as single Bar and in middle Nov-23 is coming with two bar's that is Total Value LY & Total Value TY Stating/Showing Nov-23 only as i want to See Nov-22& Nov-23Thank you
Regards,
Hari