Forum Discussion
Represent null data as zero in line chart
Hello,
I'm building a line chart that represents the evolution of the count of some Value (y axis) depending on levels. As you can see:
- The x axis starts in February 2021, with Value=3 in level 0 (thus, there are three items with value 0). There are no items in level 1 and 2.
- In April 2021, data with 1 and 2 level appears, and data with level 0 decreases.
What I'd like to obtain is a line chart where level 1 and 2 are represented from february 2021, with value=0. Graphically, this is my desired output:
I've tried adding "+0" to the measure that I've configured in my y axis, but it's been unsuccessfull. How could I achieve this?
Many thanks for your help.
Regards.
5 Replies
- FowmySuper User
Anonymous
Can you share a sample of your data?- AnonymousNot applicable
Hi Fowmy , I'm not able to attach a pbix or xlsx file, but, in order to check if this is possible, I'm using a small set of data from CSV, with this content:
ID;Level;Date
33;0;26/02/2021
33;0;31/03/2021
33;0;23/04/2021
15;1;30/01/2021
15;1;26/02/2021
15;2;31/03/2021
15;2;23/04/2021
92;1;26/02/2021
92;1;31/03/2021
92;1;23/04/2021This is my visual:
Where this is my measure Value:
Value =VAR __Value = COUNT(Hoja1[ID])RETURNIF(ISBLANK(__Value),0,__Value)And this, my desired output:Hope this is enough 🙂
- Greg_DecklerCommunity Champion
Anonymous Not sure why the +0 is not working. You might try something like:
Value = VAR __Value = SUM('Table'[Column]) RETURN IF(ISBLANK(__Value),0,__Value)Perhaps turn on "show items with no data"?
Not really enough information to go on otherwise, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2. - Hank_Helper I
Hi! Maybe substitute null values with zeros in the query?
Isn't it more efficient to do this in M rather than DAX in this case?
- Jihwan_KimSuper User
Hi, Anonymous
Please try to use the date (or month) from your Dim-Calendar table, not from your fact table.
I am not sure about how your data model looks like, but try to use Dim-calendar table in X-axis with the same measure, ( adding +0)
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Linkedin: linkedin.com/in/jihwankim1975/
Twitter: twitter.com/Jihwan_JHKIM