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
Anonymous
Not applicable

Linear Reference Line from zero to a given target value

 

Hello All,

how can I insert a linear trendline from zero to a pre-defined (max) value?

Lines are:
green: running total last year
blue: running total this year
red: target for this year

I can have the dataset for the red line but without dates, so it indicates the full monthly volume to be achieved by the end of the month.

Thank you a lot.

 

sales.jpg

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

Hi @Anonymous,

 

You can write a measure to calculate out correspond value as 'reference line', then drag it to value field to achieve your requirement:

Reference = 
VAR _current =
    SELECTEDVALUE ( 'Sample'[Index] )
VAR _min = 0
VAR _max =
    MAXX ( ALLSELECTED ( 'Sample' ), [Amount] )
RETURN
    IF (
        _current = MINX ( ALLSELECTED ( 'Sample'[Index] ), [Index] ),
        0,
        _current * _max
            / COUNTROWS ( ALLSELECTED ( 'Sample' ) )
    )

15.PNG

 

If you still confused on coding formula, please share some sample data for test.


Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
surajbh
Helper I
Helper I

@v-shex-msft  I was using the solution as above mentioned. 
If you have .pbix file, would appreciate it. if not then I have to create sample data to show why the above formula is not working on my side. 
thank you in advance for the support.  

v-shex-msft
Community Support
Community Support

Hi @Anonymous,

 

You can write a measure to calculate out correspond value as 'reference line', then drag it to value field to achieve your requirement:

Reference = 
VAR _current =
    SELECTEDVALUE ( 'Sample'[Index] )
VAR _min = 0
VAR _max =
    MAXX ( ALLSELECTED ( 'Sample' ), [Amount] )
RETURN
    IF (
        _current = MINX ( ALLSELECTED ( 'Sample'[Index] ), [Index] ),
        0,
        _current * _max
            / COUNTROWS ( ALLSELECTED ( 'Sample' ) )
    )

15.PNG

 

If you still confused on coding formula, please share some sample data for test.


Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

I am having the same issue. I have a cumulative measure that adds revenue over time, however I am trying to add a linear reference line from 0 (zero) at the beginning of the year, to the target (indicated as a SUM measure), at the end of the year. I am able to get the formula to give a strait horizontal line at zero, and I can set it a the target, but I am unable to get it to Return a line from zero to my target mesure. Could you explain the formula a bit further?

 

Aaron

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.