Hi all,
I have projects with different start date and projects investment takes for each 3 years and I need a Power BI measure that calculate the investment per year. I have only one table.
Thanks in advance for answer.
Solved! Go to Solution.
Hello @Amma17,
Please consider the following solution consisting of 2 steps:
1) You transform your initial table into the new one with the following [DAX] code.
2) You add a matrix visual, set it up and enjoy the result.
For convenience, here is the [DAX] code in plain text:
Table = ADDCOLUMNS (
( GENERATE ( SELECTCOLUMNS ( GENERATESERIES ( MIN ( data[Year] ), MAX ( data[Year] ) + 2 ), "Year", [Value] ),
VALUES ( data[Project] ) ) ),
"Investment",
VAR StartYear = YEAR ( LOOKUPVALUE ( data[Date], data[Project], [Project] ) )
RETURN SWITCH ( TRUE (),
[Year] = StartYear, LOOKUPVALUE ( data[Y1], data[Project], [Project] ),
[Year] = StartYear + 1, LOOKUPVALUE ( data[Y2], data[Project], [Project] ),
[Year] = StartYear + 2, LOOKUPVALUE ( data[Y3], data[Project], [Project] ),
0 )
)
Best Regards,
Alexander
Solve it, I created a new table that contain years and I created a relationship one to one by year, so problem was solved.
Thanks for your response.
I have another question:
How can I create another table with Investment, but split between investment proposal ( created with :
T_N = ADDCOLUMNS (
Thanks in advance
Solve it, I created a new table that contain years and I created a relationship one to one by year, so problem was solved.
Hello @Amma17,
Please consider the following solution consisting of 2 steps:
1) You transform your initial table into the new one with the following [DAX] code.
2) You add a matrix visual, set it up and enjoy the result.
For convenience, here is the [DAX] code in plain text:
Table = ADDCOLUMNS (
( GENERATE ( SELECTCOLUMNS ( GENERATESERIES ( MIN ( data[Year] ), MAX ( data[Year] ) + 2 ), "Year", [Value] ),
VALUES ( data[Project] ) ) ),
"Investment",
VAR StartYear = YEAR ( LOOKUPVALUE ( data[Date], data[Project], [Project] ) )
RETURN SWITCH ( TRUE (),
[Year] = StartYear, LOOKUPVALUE ( data[Y1], data[Project], [Project] ),
[Year] = StartYear + 1, LOOKUPVALUE ( data[Y2], data[Project], [Project] ),
[Year] = StartYear + 2, LOOKUPVALUE ( data[Y3], data[Project], [Project] ),
0 )
)
Best Regards,
Alexander
Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!