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
Anonymous
Not applicable

Calculate sum of previous month and show the difference with line chart

Hello everyone,

 

I am trying to replicate the chart for sessions by Day like the one on Google Analytics. My goal is to be able to show the difference in session for month selected and previous month using a line chart.

 

I have 2 tables, one that contains the GA data, sessions, channel and date and a second table that contains dates, which i am using to create relationships with other tables by using the Date column which has unique values.

 

Currently, I use a bar chart to display the sessions by Month, as you can see below.

Sessions by month.JPG

 

I am using the bars as a filter to display the session by day using a line chart.

 

Sessions by day.JPG

 

When none of the bars are selected, the line chart shows the total sessions by day since the beginning of 2017.

 

What I am trying to achieve is when I am selecting a month from the bar chart to have the line chart to display a line for the sessions of the month selected and a second line that will show the sessions by day for the previous month.

 

So it will look something like that

 

Sessions by day with previous month.JPG

 

My tables have the columns below

 

GA Sessions [Date]

GA Sessions [Sessions]

GA Sessions [Channel]

 

Date Series [Date] which is related to the date column of the GA Session table.

 

Any ideas on how this can be done?

 

 

Thank you in advance

 

Regards

George

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Solution found!

 

It seems that it was a lot easier that I expected. I used the formula below

 

Previous Month = CALCULATE(SUM('GA Sessions'[Sessions]), DATEADD('Date Series'[Date],-1,MONTH))

 

Now based on the month selected from the bar chart, the measure Previous month shows a line for sessions per day for the previous month of the month selected.

 

Regards

George

 

View solution in original post

3 REPLIES 3
ceebu
Advocate I
Advocate I

As far as I know this is not directly possible with PowerBI, but if you are enterprising you might be able to hack your way through something like this..

 

https://community.powerbi.com/t5/Webinars-and-Video-Gallery/Turn-Measures-On-and-Off-Inside-a-Chart-...

 

This idea uses a disconnected table to evaluate what filters are turned on and then display various values.

Anonymous
Not applicable

Hello ceebu,

 

Thank you very much for taking the time to share the video with me. It is a very interesting approach. I just don't see how it can help with the issue I have which is to calculate the sessions of the previous month based on month selected. 

 

I see how I can use the approach described in the video to add an extra filter which can say for example "Compare with previous month".

 

Regards
George

Anonymous
Not applicable

Solution found!

 

It seems that it was a lot easier that I expected. I used the formula below

 

Previous Month = CALCULATE(SUM('GA Sessions'[Sessions]), DATEADD('Date Series'[Date],-1,MONTH))

 

Now based on the month selected from the bar chart, the measure Previous month shows a line for sessions per day for the previous month of the month selected.

 

Regards

George

 

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.