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.
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
JAN | FEB | MAR | APR | MAY | JUNE | JULY | AUG | SEP | OCT | NOV | DEC | |
2021 YOY % | 2021 Actual VS Last year Same month Actual | 2021 Predicted VS Last year 2020 Actual Value | 2021 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 |
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 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.
Hi, @Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
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.
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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:
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:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
94 | |
82 | |
66 | |
59 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |