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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
smjzahid
Helper V
Helper V

How to emulate Line Chart from Excel to Power BI

I have a Line Chart that I want to exactly emulate in Power BI. The table below shows sample data on which the report is to be built

Here is the LINE CHART in EXCEL, Please note that date on X Axis in excel chart (which has shows value for every 7 days)

 

 

image.png

 

 

However, when I try this Line Chart in Power BI it do not show the data (meaning days split every 7 days) as above excel visual, I have tried to change the X AXIS from (Categorical to Continous) but do not get it to work.

 

I have the date column formatted as date and value or the number column as Whole number,

 

Any idea how do I get this to show data as shown in excel

 

image.png

 

 

 

 

  02/01/2103/01/2104/01/2105/01/2106/01/2107/01/2108/01/2109/01/2110/01/2111/01/2112/01/2113/01/2114/01/2115/01/2116/01/2117/01/2118/01/2119/01/2120/01/2121/01/2122/01/2123/01/2124/01/2125/01/2126/01/2127/01/2128/01/2129/01/2130/01/2131/01/2101/02/2102/02/21
PilingBaseline        038131823232326313641454545454545454545454853
Actual   117666666623232321282936424848515959606767676767
Pile CapsBaseline                                
Actual                                
Shell BoxesBaseline                                
Actual                                
Cill BeamsBaseline                                
Actual                                
BearingsBaseline                                
Actual                                
Y BeamsBaseline                                
Actual                                
1 ACCEPTED SOLUTION

@smjzahid 

To create a date table:

Let's say your date field in your fact table is 'FactTable'[Date]

Go into the Modeling option in the ribbon and select new table. Now type in the following code:

 

DateTable = 
VAR MinDate = MIN(FactTable[Date])
VAR MaxDate = MAX(FactTable[Date])
RETURN
ADDCOLUMNS(CALENDAR(MinDate, MaxDate), 
"Year", YEAR([Date]),
"Month Numb", MONTH([Date]),
"Month", FORMAT([Date], "MMM"),
"Week Number", WEEKNUM([Date])
)

 

If you already have a date table with continuous dates covering the range of dates in your model, you can add new columns using the code for each column as above. For example,

Year = YEAR(DateTable[Date])

and

Week Number = WEEKNUM(DateTable[Date])

 

 (apologies since my settings are in spanish. Hence the month names)
datetable.JPG

Now add a new column to this table in the ribbon and add this code:

 

7 Day Axis = CALCULATE(MIN(DateTable[Date]), ALLEXCEPT(DateTable, DateTable[Week Number], DateTable[Year]))

 

 

Captura.JPG

 

Finally go to the modeling pane and join both date fields in a one-to-many relationship

2021-02-06.png

 

You have now created a Date Table and you should use the fields from this table in your visuals, slicers, filters, measures etc. You can also now use Time Intelligence functions for your calculations using this table.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

5 REPLIES 5
PaulDBrown
Community Champion
Community Champion

@smjzahid 

1) create a new column in the date table with the following (If you prefer the day reference to be the last day of the week use MAX instead of MIN)

7 day axis.JPG

 

 

2) Create the line chart using this "7 day axis" column. Set the axis to categorical:

Result.JPG

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi @PaulDBrown ,

 

Thanks for your reply, How have you created the WEEK NUMBER and YEAR columns in your date table as I do not have those columns in my table, I just have a date column (that too not even a complete year). The Min date is 10/2020 and MAX is 05/2021

@smjzahid 

To create a date table:

Let's say your date field in your fact table is 'FactTable'[Date]

Go into the Modeling option in the ribbon and select new table. Now type in the following code:

 

DateTable = 
VAR MinDate = MIN(FactTable[Date])
VAR MaxDate = MAX(FactTable[Date])
RETURN
ADDCOLUMNS(CALENDAR(MinDate, MaxDate), 
"Year", YEAR([Date]),
"Month Numb", MONTH([Date]),
"Month", FORMAT([Date], "MMM"),
"Week Number", WEEKNUM([Date])
)

 

If you already have a date table with continuous dates covering the range of dates in your model, you can add new columns using the code for each column as above. For example,

Year = YEAR(DateTable[Date])

and

Week Number = WEEKNUM(DateTable[Date])

 

 (apologies since my settings are in spanish. Hence the month names)
datetable.JPG

Now add a new column to this table in the ribbon and add this code:

 

7 Day Axis = CALCULATE(MIN(DateTable[Date]), ALLEXCEPT(DateTable, DateTable[Week Number], DateTable[Year]))

 

 

Captura.JPG

 

Finally go to the modeling pane and join both date fields in a one-to-many relationship

2021-02-06.png

 

You have now created a Date Table and you should use the fields from this table in your visuals, slicers, filters, measures etc. You can also now use Time Intelligence functions for your calculations using this table.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






negi007
Community Champion
Community Champion

@smjzahid did you try the option of creating a new column which can be used in your x-axis like below

Week = 'Date'[Date].[Day]& "/" & 'Date'[Date].[MonthNo] & "/" & RIGHT('Date'[Date].[Year],2) & "" & "/W"& WEEKNUM('Date'[Date],2)
 

negi007_0-1612614450412.png

 

your line chart could be like this

negi007_2-1612614524590.png

 

 

 




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

@negi007 , Thanks for your reply, it does not show the data as per the Excel chart as shown above, Look how there is a interval of every 7 days on the excel chart between 2 dates, your formuala does not achieve this 

 

image.png

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.