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
somulaj
Regular Visitor

forcing zeros to draw a continuous line

Hi,

 

I have Date and Sales columns in the database. I would like to see how my sales are changing by month using a line graph.

There is no entry for April 2020 in the database. So in my line graph, i do see continous graph till march 2020 and agian line will start from May 2020 and the continuity is missing for the month April 2020.

 

Is there any way I can force the line for April 2020 with 0 sales. 

 

Thanks,

Jay

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @somulaj 

According to your description, I can understand your problem, I think you can solve this problem using a calendar table and a measure, you can follow my steps:

This is my test data:

v-robertq-msft_0-1621935723259.png

 

  1. Create a calendar table a calculated column in the table:
Date = CALENDAR(DATE(2021,1,1),DATE(2021,8,31))
Year month = YEAR([Date])&"-"&MONTH([Date])

Then give them a relationship with the date column:

v-robertq-msft_1-1621935723261.png

 

  1. Create a measure in the main table:
Sales value =

var _sum=SUM('Table'[Sales])

return

IF(_sum=BLANK(),0,_sum)
  1. Create a line chart and place it like this:

v-robertq-msft_2-1621935723268.png

 

And you can get what you want.

You can download my test pbix file below

 

If you still have a problem, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

View solution in original post

6 REPLIES 6
v-robertq-msft
Community Support
Community Support

Hi, @somulaj 

According to your description, I can understand your problem, I think you can solve this problem using a calendar table and a measure, you can follow my steps:

This is my test data:

v-robertq-msft_0-1621935723259.png

 

  1. Create a calendar table a calculated column in the table:
Date = CALENDAR(DATE(2021,1,1),DATE(2021,8,31))
Year month = YEAR([Date])&"-"&MONTH([Date])

Then give them a relationship with the date column:

v-robertq-msft_1-1621935723261.png

 

  1. Create a measure in the main table:
Sales value =

var _sum=SUM('Table'[Sales])

return

IF(_sum=BLANK(),0,_sum)
  1. Create a line chart and place it like this:

v-robertq-msft_2-1621935723268.png

 

And you can get what you want.

You can download my test pbix file below

 

If you still have a problem, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

Thank you. Its worked

HashamNiaz
Solution Sage
Solution Sage

Hi @somulaj !

 

You can write your DAX measure as following;

 

Sales1 = IF(ISBLANK([Sales], 0, [Sales])

 

You can replace [Sales] measure with your measure calculation. Hope this will solve.

 

Regards,

Hasham

Hi Hasham,

 

If I have an entry for April 2020 in my database with blank sales then I can write DAX. My question is how do we get April 2020 Date in the database. 

 

Thnaks,

Jay

Hi,

Ensure you have a Calendar Table.  Build a relationship from the Date column of your Table to the Date column of your Calendar Table.  In the Calendar Table, write calculated column formulas to extract Year, Month name and Month number.  Sort the Month name column by the Month number.  To your visual, drag Year and Month name column from the Calendar Table.  Write this measure

Sales = coalesce(sum(data[amount]),0)

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @somulaj !

You are using Calendar / Date dimension in your Data Model. You data model Calendar dimension should have all the dates irrespective of your sales.

 

You can plot the sales again Calendar dimension date, and you can set the property to show items with no data.

 

You can create a basic Calendar table using below DAX; go to Modeling -> New Table;

Calendar = CALENDARAUTO()

 

Then connect this table with your Fact (Sales) table using Date key.

 

Regards,

Hasham

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.