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

Display YOY % based on Actual Vs Predicted Values

Hi All,

 

I have to Dynamically calculate values based on the Actual and Predicted values Following are the scenarios

 

Scenario 1:  YOY of Current Month (Latest Actual Vs Last year same month Actual)

Scenario 2:   YOY of Current Month +1 & +2 (Predicted value of +1 month Vs Actual value of last year same month) same for +2

 

Scenario 3: YOY of Current Month +3 to Till end of the year. ( Last Year Actual Vs Before Last year Actual 

 

The report will be like below, with detailed ( Am confused to put all these together) Please help me to create calculations 

 

 JANFEBMARAPRMAYJUNEJULYAUGSEPOCTNOVDEC
2021 YOY %2021 Actual VS Last year Same month Actual2021 Predicted VS Last year 2020 Actual Value2021 Predicted VS Last year 2020 Actual Value

2020 Actual VS Last year 2019 

 Actual Value

2020 Actual VS Last year 2019 

 Actual Value

2020 Actual VS Last year 2019 

 Actual Value

2020 Actual VS Last year 2019 

 Actual Value

2020 Actual VS Last year 2019 

 Actual Value

2020 Actual VS Last year 2019 

 Actual Value

2020 Actual VS Last year 2019 

 Actual Value

2020 Actual VS Last year 2019 

 Actual Value

2020 Actual VS Last year 2019 

 Actual Value

 

 

5 REPLIES 5
Anonymous
Not applicable

Hi @v-alq-msft , 

 

Thanks a lot for your time and giving me the option to implement, I have got almost solution and am trying to fit it into my logic,, i will try to explain what I am trying to accomplish

 

Report Display one row Jan to December

 

Columns 

Actual Calc DatePredict Calc DateActual ValuePredict Value

 

YOY calculation for Current month

(Current Month Actual - Last year same month Actual)/Last year same month Actual

 

YOY calculation for Current month +1

(Current Month+1 Predict Value - Last year same month Actual)/Last year same month Actual

 

YOY calculation for Current month +2

(Current Month+2 Predict Value - Last year same month Actual)/Last year same month Actual

 

Rest all 

YOY calculation for Current month

(Previous Year Current Month Actual - Before Last year same month Actual)/Before Last year same month Actual

 

Am trying to attach the sample file but am not able to see the option, please suggest me the best way to share the file. 

v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

d1.png

 

YearMonth(a calculated table):

YearMonth = DISTINCT('Table'[YearMonth])

 

You may create measures as below.

Current YearMonth Actual = 
CALCULATE(
    SUM('Table'[Actual Value]),
    FILTER(
        ALL('Table'),
        [YearMonth]=MAX('YearMonth'[YearMonth])
    )
)
Current YearMonth+1 Actual = 
CALCULATE(
    SUM('Table'[Actual Value]),
    FILTER(
        ALL('Table'),
        [YearMonth]=
        CALCULATE(
            MIN(YearMonth[YearMonth]),
            FILTER(
                ALL(YearMonth),
                [YearMonth]>MAX('YearMonth'[YearMonth])
            )
        )
    )
)
Current YearMonth+1 Predict = 
CALCULATE(
    SUM('Table'[Predict Value]),
    FILTER(
        ALL('Table'),
        [YearMonth]=
        CALCULATE(
            MIN(YearMonth[YearMonth]),
            FILTER(
                ALL(YearMonth),
                [YearMonth]>MAX('YearMonth'[YearMonth])
            )
        )
    )
)
Current YearMonth+2 Actual = 
var ym = MAX('YearMonth'[YearMonth])
var val = 
CALCULATE(
        MAX('YearMonth'[YearMonth]),
        TOPN(
                2,
                FILTER(
                    ALL(YearMonth),
                    [YearMonth]>ym
                ),
                [YearMonth],ASC
        )
)
return
CALCULATE(
    SUM('Table'[Actual Value]),
    FILTER(
        ALL('Table'),
        [YearMonth]=val
        
    )
)
Current YearMonth+2 Predict = 
var ym = MAX('YearMonth'[YearMonth])
var val = 
CALCULATE(
        MAX('YearMonth'[YearMonth]),
        TOPN(
                2,
                FILTER(
                    ALL(YearMonth),
                    [YearMonth]>ym
                ),
                [YearMonth],ASC
        )
)
return
CALCULATE(
    SUM('Table'[Predict Value]),
    FILTER(
        ALL('Table'),
        [YearMonth]=val
        
    )
)
Rest Actual = 
var ym = MAX('YearMonth'[YearMonth])
var res = 
CALCULATE(
        SUM('Table'[Actual Value]),
        FILTER(
            ALL('Table'),
            [YearMonth]>ym&&
            NOT(
                [YearMonth] in
                TOPN(
                        2,
                        FILTER(
                            ALL(YearMonth),
                            [YearMonth]>ym
                        ),
                        [YearMonth],ASC
                )
            )&&
            LEFT([YearMonth],4)=LEFT(ym,4)
        )
    )
return
res
Rest Predict = 
var ym = MAX('YearMonth'[YearMonth])
var res = 
CALCULATE(
        SUM('Table'[Predict Value]),
        FILTER(
            ALL('Table'),
            [YearMonth]>ym&&
            NOT(
                [YearMonth] in
                TOPN(
                        2,
                        FILTER(
                            ALL(YearMonth),
                            [YearMonth]>ym
                        ),
                        [YearMonth],ASC
                )
            )&&
            LEFT([YearMonth],4)=LEFT(ym,4)
        )
    )
return
res

 

And the calculations for Last YearMonth are similar. Finally you may use 'YearMonth' column from 'YearMonth' table to filter the result.

d2.png

 

Best Regards

Allan

 

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

Anonymous
Not applicable

Hi @v-alq-msft 

 

Thanks a lot for your solution, really great tricks been used.

 

Can i show all these in one matrix/table visual by sharing across the year.

 

 

 

 

Hi, @Anonymous 

 

You may try creating the following table by 'Enter Data'. The pbix file is attached in the end.

Test:

a1.png

 

Then you create a measure as below.

Result = 
IF(
    ISINSCOPE(Test[Num]),
    SWITCH(
        SELECTEDVALUE(Test[Time Preiod]),
        "Current",
        IF(
            SELECTEDVALUE('Test'[Actual/Predict])="Actual",
            SWITCH(
                SELECTEDVALUE(Test[Num]),
                1,[Current YearMonth+1 Actual],
                2,[Current YearMonth+2 Actual],
                [Current YearMonth Actual]
            ),
            IF(
                SELECTEDVALUE(Test[Actual/Predict])="Predict",
                SWITCH(
                    SELECTEDVALUE(Test[Num]),
                    1,[Current YearMonth+1 Predict],
                    2,[Current YearMonth+2 Predict]
                )
            )
        ),
        "Last",
        IF(
            SELECTEDVALUE(Test[Actual/Predict])="Actual",
            SWITCH(
                SELECTEDVALUE(Test[Num]),
                1,[Last YearMonth+1 Actual],
                2,[Last YearMonth+2 Actual],
                [Last YearMonth Actual]
            ),
            IF(
                SELECTEDVALUE(Test[Actual/Predict])="Predict",
                SWITCH(
                    SELECTEDVALUE(Test[Num]),
                    1,[Last YearMonth+1 Predict],
                    2,[Last YearMonth+2 Predict]
                )
            )
        ),
        "Rest",
        SWITCH(
            SELECTEDVALUE(Test[Actual/Predict]),
            "Actual",[Rest Actual],
            "Predict",[Rest Predict]
        )
    )
)

 

Result:

a2.png

 

Best Regards

Allan

 

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

Anonymous
Not applicable

Thanks a lot for your time and giving me the option to implement, I have got almost solution and am trying to fit it into my logic, i will try to explain what I am trying to accomplish

Report Display one row Jan to December

Columns 

Actual Calc Date

Predict Calc Date

Actual Value

Predict Value


YOY calculation for Current month

(Current Month Actual - Last year same month Actual)/Last year same month Actual

YOY calculation for Current month +1

(Current Month+1 Predict Value - Last year same month Actual)/Last year same month Actual

YOY calculation for Current month +2

(Current Month+2 Predict Value - Last year same month Actual)/Last year same month Actual

Rest all 

YOY calculation for Current month

(Previous Year Current Month Actual - Before Last year same month Actual)/Before Last year same month Actual

 

Am trying to attach the sample file but am not able to see the option, please suggest me the best way to share the file. 

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.