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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Unicorn_Tech
Resolver I
Resolver I

Line Chart, with comparison time

Hello.  I have a Line chart, showing pageviews over time.

 

I want to add a second line, comparing the date period chosen to the previous period.

Is there an easy way to do this?

1 ACCEPTED SOLUTION

@Unicorn_Tech you need to set relationship between date table and your original table and then you can use parallelperiod function as described in the link.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

@Unicorn_Tech As a best practice, add date dimension in your model and use it for and time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools.

https://perytus.com/2020/05/22/create-a-basic-date-table-in-your-data-model-for-time-intelligence-ca...

 

Once you have date dimension in your model, you can use previousday, previousmonth, previousyear, all these time intelligence functions in your measure

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@

 

Hi @Unicorn_Tech ,

 

When we use time intelligence function. It always need a complete, uninterrupted calendar table.  You need create a date table and create relationship between it and original.

 

Here is two link that many help you learn more about it:

 

https://softcrylic.com/blogs/power-bi-for-beginners-how-to-create-a-date-table-in-power-bi/

https://www.sqlbi.com/articles/time-intelligence-in-power-bi-desktop/

 

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

 

Best Regards,

Dedmon Dai

@v-deddai1-msft @parry2k , I really appreciate your help here.

I have my seperate date table.  I have marked it as a date table.  I have set up a relationshipt between the Date table (Date) to my data table with page views (Date.)

I don't understand how now to calculate a parallel period.  Is this done in a table, an extra column?  Is this done in the reporting view?

My visual is a line chart that shows page views for the past 30 days.  I am now using the field of date from the date table, and the page views column from the data table.

How can I now show a seperate line, with the parallel period.

I appreciate the help - I am learning!

Hello.  Based on internet links, this is what I tried to do, inside my date table:

Date =
VAR __dates = CALENDARAUTO()
RETURN
ADDCOLUMNS (
__dates,
"Year", YEAR ( [Date] ),
"Month Number", MONTH ( [Date] ),
"Month Name", FORMAT ( [Date], "MMMM" ), --use MMMM for full month name, January instead of Jan
"Month", FORMAT( [Date], "MMM, YYYY" ), --use MMMMM for full month name, January instead of Ja
"Month Sort", FORMAT( [Date], "YYYY-MM" ),
"Quarter", "Q" & FORMAT( [Date], "Q, YYYY" ),
"Quarter Sort", FORMAT ( [Date], "YYYY-Q" ),
"Par", calculate(sum('All Web Site Data'[Pageviews]),'All Web Site Data'[Date],PARALLELPERIOD('All Web Site Data'[Date],-1,MONTH)
)
 
The bold text is returning the same value for each row, rather than returning the total page views for the particular date, in the parallel period.

@Unicorn_Tech you need to set relationship between date table and your original table and then you can use parallelperiod function as described in the link.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors