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
MyThumbsClick
Helper I
Helper I

Count by Month - Line Graph Not Showing Zero Values

Hi All

 

I have a Projects table - example below:

Project_IDGo_Live_Date

1

01/01/2024
212/01/2024
311/03/2024
401/04/2024

I have a line graph visulation with:

  • X-axis - Go_Live_Date (date hierarchy - Year, Month)
  • Y-axis - Count of Project_ID

This works fine and shows total projects per month except its not showing a zero value for Feb when there is no project with a Go_Live_Date. Do I need to create a seperate Count measure and use some clever DAX?

 

Thanks!

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Try this approach.

  1. Create a Calendar Table with calculated column formulas for Year, Month name and Month number. Sort the Month name column by the Month number
  2. Create a relationship (Many to One and Single) from the Go_Live_Date column to the Date column of the Calendar Table
  3. to your visual, drag Year and Month name from the Calendar Table
  4. Write this measure

Measure = coalesce(distinctcount(AllProjects[ID]),0)

Hope this helps.


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

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

Try this approach.

  1. Create a Calendar Table with calculated column formulas for Year, Month name and Month number. Sort the Month name column by the Month number
  2. Create a relationship (Many to One and Single) from the Go_Live_Date column to the Date column of the Calendar Table
  3. to your visual, drag Year and Month name from the Calendar Table
  4. Write this measure

Measure = coalesce(distinctcount(AllProjects[ID]),0)

Hope this helps.


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

Hi Ashish

I do have 1 more query if thats ok? I would like to add a filter to the measure dependant on another column value. Something like this: 

measure = CALCULATE(coalesce(distinctcount(AllProjects[id]),FILTER(AllProjects,[m_a] = "True"),0))

 

However, im getting the following error: The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

Is there a way to achieve this?

Thanks

Hi,

Does this measure work?

Measure = coalesce(calculate(distinctcount(AllProjects[id]),AllProjects[m_a] = "True"),0)

If TRUE is a boolean value, then remove the double quotes.

Hope this helps.


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

Thats worked perfectly. Thank you

You are welcome.


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

Thanks. With your instructions (and a bit of fiddling with the sort), the graph is visualizing as i want it. 

 

Greatly appreciated! 

You are welcome.


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

Hello @MyThumbsClick ,

 

Yes you have to create separate measure for the count and after creating measure at the end of the measure please mention '+0' so that if the value is blank it will show '0'

 

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

Thanks Kishore_KVN

 

I created the below basic measure which does the trick and shows a zero value for where there is no count.
projects_per_month_count = DISTINCTCOUNT(AllProjects[id])+0

 
The problem im having is that i want to display the graph with a relative date filter - ''Is in the next 12 months". So Jan - March should be for months in 2025 and should appear after December but they are showing as if in normal calendar year. I have a feeling i cant achieve what im after with just a measure?

MyThumbsClick_0-1712612457386.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.