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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Rashidb84
Resolver I
Resolver I

Including a zero value period in Line chart calculated via Measure

Hi Guys,

 

I've created a line Chart by using two measures:

 

Blue line

Rashidb84_1-1708713554043.png

 

Green line

Rashidb84_2-1708713583654.png

The line chart result is as follows:

 

 

Rashidb84_0-1708713489264.png

 

How can I make sure the blue line which has a value of ZERO in P5 is pulled through?

Is that possible with a measure?

 

I know that some things unfortunately aren't possible with Measures in PowerBI.

 

Thank you!!!

2 ACCEPTED SOLUTIONS
nsexton12
Resolver II
Resolver II

Your issue is that the count function returns null instead of 0 if there are no values. So, you need to modify your formula with an IF statement to allow it to return 0 when the count is 0. The formula is below. 

 

CALCULATE1 = IF(CALCULATE(COUNT(Table2[Profit Center]),FILTER(Table2,Table2[Profit Center] = "P736064")) = 0, 0 ,CALCULATE(COUNT(Table2[Profit Center]),FILTER(Table2,Table2[Profit Center] = "P736064")))

View solution in original post

Rashidb84
Resolver I
Resolver I

Hi nsexton12,

 

Thank you very much for your help. I will try the advised formula for my learning process. 

I literally just sorted the issue slightly differently:

NEW formula Blue line:

Stock PO's GR'd by Finance =
VAR ForceZero = COUNTROWS('3 Source_KE5Z') > 0
VAR Amt = calculate(count('3 Source_KE5Z'[Profit Center]),filter('3 Source_KE5Z','3 Source_KE5Z'[Profit Center]="P736064")) + If(ForceZero, 0)
RETURN Amt
 
 
result
Rashidb84_0-1708715032932.png

 

Keep learning.

View solution in original post

4 REPLIES 4
Rashidb84
Resolver I
Resolver I

Hi nsexton12,

 

Thank you very much for your help. I will try the advised formula for my learning process. 

I literally just sorted the issue slightly differently:

NEW formula Blue line:

Stock PO's GR'd by Finance =
VAR ForceZero = COUNTROWS('3 Source_KE5Z') > 0
VAR Amt = calculate(count('3 Source_KE5Z'[Profit Center]),filter('3 Source_KE5Z','3 Source_KE5Z'[Profit Center]="P736064")) + If(ForceZero, 0)
RETURN Amt
 
 
result
Rashidb84_0-1708715032932.png

 

Keep learning.

Nice! There are always many ways to solve each problem. Could you please mark my reply as a solution if it worked for you?

Yes, It did work. Took a little longer as I'm new to PBI and tried to apply it to my situation.

 

Thank you!!!

nsexton12
Resolver II
Resolver II

Your issue is that the count function returns null instead of 0 if there are no values. So, you need to modify your formula with an IF statement to allow it to return 0 when the count is 0. The formula is below. 

 

CALCULATE1 = IF(CALCULATE(COUNT(Table2[Profit Center]),FILTER(Table2,Table2[Profit Center] = "P736064")) = 0, 0 ,CALCULATE(COUNT(Table2[Profit Center]),FILTER(Table2,Table2[Profit Center] = "P736064")))

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.