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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
gbarr12345
Post Prodigy
Post Prodigy

Help with Line Chart

Hi,

 

I'm trying to create a line chart to compare the number of Volume create against the numbers of volume sold to customers (Depletion in my sample file) for 2 products - Pinot Grigio and Premium Red Wine.

 

I created relationships and they seem to be ok with one to many's.

 

However when I drag the data in the USA 9LE or volume seems ok but the Depletion 9LE is all the same number for Pinot Grigio and showing nothing for Premium Red Wine even though there should be data - Sample data in my screenshot below:

 

gbarr12345_0-1722462926424.png

 

I want to create an accurate line chart to compare the US 9LE against the Depletion 9LE - example below but dark blue line needs to be different too:

 

gbarr12345_1-1722462980352.png

 

Can anybody help me in achieving this? I've attached the sample PBI file below and also the Excel file I created to make this graph.

 

PBI File - https://drive.google.com/file/d/1xa9DqZ6Ck1YSook6a4zWVDa8yYCQjKFE/view?usp=drive_link

 

Excel - https://docs.google.com/spreadsheets/d/1A80g-0NjgtS4dgVcwLmglWIyrfH4eoVK/edit?usp=sharing&ouid=11647...

 

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

hi @gbarr12345 ,

 

this link has the code with variable start and end date: 

 

avixd/CalendarTable_with_DAX: Code samples of a calendar table using DAX (github.com) 

 

Change what is highlighted in yellow for the output:

adudani_0-1722472050351.png





Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

View solution in original post

8 REPLIES 8
adudani
Super User
Super User

hi @gbarr12345 ,

Attached is my solution and an image of the output. Let me know if this meets the requirements.

 

steps taken:

1. added a date table.

2. Create 1 to many relationships from dimensions to facts.

3. Used the date from the date table instead of the depleation/usa table.

adudani_0-1722467968478.png

 

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Thank you for your response.

 

How did you create the date table do you mind me asking?

hi @gbarr12345 ,

 

references below have open source code.

 

using dax, you could create a new table and copy paste the dax code. Walk throughs of the code is in the videos.

Here is how to make it via DAX: Calendar Table using DAX (youtube.com) 

 

Using a blank query, copy paste the code into the advanced editor in power query:

Power BI Ultimate Calendar Table 🗓️ / Date Table 📆 [ FREE DOWNLOAD ] (youtube.com)

 

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Thank you for your response.

 

I have this code for a Date column but I want it to start from the year 2020 and end in the year 2025. Is there a way to altewr my formula to do this do you know?

 

ADDCOLUMNS(

    CALENDARAUTO(),

    "Dates" , FORMAT([Date], "DD/MM/YYYY"),

    "Year", YEAR([Date]),

    "Month" , FORMAT([Date] , "mmmm"),

    "Quarter" , FORMAT([Date] , "\QQ"),

    "Month Year", FORMAT([Date], "mmm yyyy"),

    "Day" , DAY([Date]),

    "Month Number" , MONTH([Date])

)

hi @gbarr12345 ,

 

this link has the code with variable start and end date: 

 

avixd/CalendarTable_with_DAX: Code samples of a calendar table using DAX (github.com) 

 

Change what is highlighted in yellow for the output:

adudani_0-1722472050351.png





Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Perfect thanks, that worked!

 

One more question, I copied your relationships, etc and for some reason the numbers for the depletion are still the same instead of giving me the correct number:

 

gbarr12345_0-1722474225952.png

 

gbarr12345_1-1722474244880.png

 

 

Any idea as to why that's happening?

is the "Date" in the row context from "DimDate" ?
Also, is DimDate marked as the Date table?

adudani_0-1722475296380.png

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Alternatively, 

 

with the "DimDate" i provided in the sample output previously.

you could also modify the start and end date as shown below in the advanced editor

adudani_1-1722472219405.png

 

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Kudoed Authors