The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I am relatively new to PowerBI and was struggling to find an answer. I am trying to find a way to create a line graph with YTD data being used for the first part and calculated data for today to EOY. e.g:
month | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
data | 5 | 10 | 16 | 23 | 28 | 32 | 35 | 40 | 45 | 50 | 55 | 60 |
In blue is data I can get and in red is data I have to forecast based on YTD trend.
I have tried creating a for loop:
Trend_forloop =
// Provide some starting values
VAR __sum = [raw data]
VAR __loopTable = GENERATESERIES(1,12)
VAR __loopTable1 = ADDCOLUMNS(__loopTable,"__sum",__sum + SUMX(FILTER(__loopTable,[Value]<=EARLIER([Value])),[Value]))
VAR __max = 12
RETURN
//here is where the issue arises
CALCULATE(VALUES(__loopTable1[__sum]),
FILTER(ALL(__looptable1[Value], __looptable1[Value] = max (__loopTable1[Value]))))
As you can see above I am unsure how to do the final step here. Any insights would be appreciated.
I am also open to any alternative ways of doing this (not a for loop).
Thanks
@TL_LCH , Can you share raw data.
You need like
YTD = CALCULATE(if(Max(Date[Date]) <= eomonth(Today(),-1), SUM(Actual[Actual]) , SUM(Forecast[Forecast]) ) ,DATESYTD('Date'[Date],"12/31"))