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

How do you use the Average line results created in from the analytic tab in a calculation?

I have created a Area line chart and included an average line which works great. What I want to do now is include a calculation that will take the results of the average line witch will create another line that will represent the % difference for average.

ll84744_0-1637868341677.png

I can manualy include the number in the calculation but the data it going to change based on the filtering therefor the average will also change.

This is the calculation I am using.

Case_Count % difference from SLR-06 =
VAR __BASELINE_VALUE = 2357

    
VAR __MEASURE_VALUE = SUM('SLRCaseData'[Case_Count])
RETURN
    IF(
        NOT ISBLANK(__MEASURE_VALUE),
        DIVIDE(__MEASURE_VALUE - __BASELINE_VALUE, __BASELINE_VALUE)
    )

 

 

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Try these measures

Avg of Year = 
VAR vYear = MAX('Table'[Year])
RETURN
CALCULATE(SUM('Table'[Case_Count]),ALL('Table'),'Table'[Year]=vYear)/12
Case_Count % difference from SLR-06 = 
VAR __BASELINE_VALUE = [Avg of Year]
VAR __MEASURE_VALUE = SUM('Table'[Case_Count])
RETURN
    IF(
        NOT ISBLANK(__MEASURE_VALUE),
        DIVIDE(__MEASURE_VALUE - __BASELINE_VALUE, __BASELINE_VALUE)
    )

21120201.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

6 REPLIES 6
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Try these measures

Avg of Year = 
VAR vYear = MAX('Table'[Year])
RETURN
CALCULATE(SUM('Table'[Case_Count]),ALL('Table'),'Table'[Year]=vYear)/12
Case_Count % difference from SLR-06 = 
VAR __BASELINE_VALUE = [Avg of Year]
VAR __MEASURE_VALUE = SUM('Table'[Case_Count])
RETURN
    IF(
        NOT ISBLANK(__MEASURE_VALUE),
        DIVIDE(__MEASURE_VALUE - __BASELINE_VALUE, __BASELINE_VALUE)
    )

21120201.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

VahidDM
Super User
Super User

HI @Anonymous 

 

Try this:

Case_Count % difference from SLR-06 =
VAR __BASELINE_VALUE = calculate(SUM('SLRCaseData'[Case_Count]),removefilters('SLRCaseData'[Date Column]))
VAR __MEASURE_VALUE = SUM('SLRCaseData'[Case_Count])
RETURN
    IF(
        NOT ISBLANK(__MEASURE_VALUE),
        DIVIDE(__MEASURE_VALUE - __BASELINE_VALUE__BASELINE_VALUE)
    )
 
Date Column: change this to the column you used as an axis of the visual.
 
 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/


 

Anonymous
Not applicable

Unfortunatly that did not work.

VAR __BASELINE_VALUE = CALCULATE(sum('SLRCaseData'[Case_Count]),Removefilters(SLRCaseData[Closed Date]))
I am thinking that the Baseline_Value calculation is not returning the correct result based on the filters applied for the time frame. When using the analstics/average line it shows a consist result  "2357" accross the entire time frame. If I could recreate that calculation.

 

@Anonymous 

 

Can you post sample data as text and expected output?
Not enough information to go on;

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.
4. Relation between your tables

Appreciate your Kudos!!
LinkedIn:www.linkedin.com/in/vahid-dm/

Anonymous
Not applicable

My expected out come is;

Line A - To have a line with the total number of cases for each month for the time span selected. In this case 1 year.

Line B - To have a Monthly average line representing the average number of case counts expected to recieve each month - nice flat line.

Finially a secondary line that would represent the % difference from Line A and line B.

ll84744_0-1637940766640.png

YearMonthCase_CountAmdocsSoft_IMACsum of cases for year /12%inc/decr
2018January213338417492479-16%
2018February163926813712479-51%
2018March200031716832479-24%
2018April238241219702479-4%
2018May245138320682479-1%
2018June229234719452479-8%
2018July239734520522479-3%
2018August27684222346247910%
2018September28494272422247913%
2018October33164322884247925%
2018November32703702900247924%
2018December225629819582479-10%
2019January290234825542996-3%
2019February241233920732996-24%
2019March257140021712996-17%
2019April264642522212996-13%
2019May33664442922299611%
2019June281940924102996-6%
2019July287439424802996-4%
2019August288141624652996-4%
2019September35273413186299615%
2019October38284133415299622%
2019November35353613174299615%
2019December259429822962996-16%

 

Anonymous
Not applicable

Calculate the average based sum of month over the year.

Line A - To have a line with the total number of cases for each month for the time span selected. In this case 1 year.

Line B - To have a Monthly average line representing the average number of case counts expected to recieve each month - nice flat line.

Finially a secondary line that would represent the % difference from Line A and line B.

ll84744_0-1638363566503.png

YearMonthAAmdocsSoft_IMACB - sum of cases for year /12%inc/decr
2018January213338417492479-16%
2018February163926813712479-51%
2018March200031716832479-24%
2018April238241219702479-4%
2018May245138320682479-1%
2018June229234719452479-8%
2018July239734520522479-3%
2018August27684222346247910%
2018September28494272422247913%
2018October33164322884247925%
2018November32703702900247924%
2018December225629819582479-10%
2019January290234825542996-3%
2019February241233920732996-24%
2019March257140021712996-17%
2019April264642522212996-13%
2019May33664442922299611%
2019June281940924102996-6%
2019July287439424802996-4%
2019August288141624652996-4%
2019September35273413186299615%
2019October38284133415299622%
2019November35353613174299615%
2019December259429822962996-16%

 

Hope this helps

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.

Top Solution Authors