Forum Discussion
Virtual Tables and Columns not working as expected
planc7 Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, 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.
- planc72 years ago
Helper I
Thank you for your reply.
Unfortunately I wasn't able to find any solution in the forum.
Anyway, here below the sample of data.
Essentially, I need to create a virtual column (Actual Planned PY) that repeats Actual/Planned number for each row with the same @Key but only for the next year.
I manage it with a measure, and the measure works, but I need to insert the new column (Actual Planned PY) in a matrix, and here is the point where I have the problem
Here the measure used to recreate the Virtual Table and the Column needed (Actual Planned PY)
VAR _Table =
ADDCOLUMNS(
'PHISICAL_TABLE',
"@Key",
IF(NOT ISBLANK(PHISICAL_TABLE[Actual/Planned]),
PHISICAL_TABLE[Year]+1&FORMAT(PHISICAL_TABLE[Week],"00")&'PHISICAL_TABLE'[Brand]&'PHISICAL_TABLE'[Cluster],
PHISICAL_TABLE[Key Brand])
)
VAR _Table1=
ADDCOLUMNS(
_Table,
"@Actual/PlannedPY",
IF(ISBLANK(PHISICAL_TABLE[Actual/Planned]),
CALCULATE(
MAX ( PHISICAL_TABLE[Actual/Planned] ),
FILTER (
_Table,
[@Key] = EARLIER ( [@Key] )))))
RETURN
SUMX(_Table1, [@Actual/PlannedPY])Just for information, this is the table output of variable _Table1:The problem encountered is the following: on left the matrix that I actually got doing this formula, on the right the expected one.Thank you in advance!Year Week Brand Cluster Key Brand Actual/Planned Year&Week Year+1 2023 51 XX 2024-AA 202351XX2024-AA 4 202351 2024 2024 51 XX 2024-AA 202451XX2024-AA 202451 2025 2023 50 XX 2024-AA 202350XX2024-AA 4 202350 2024 2024 50 XX 2024-AA 202450XX2024-AA 202450 2025 2023 49 XX 2024-AA 202349XX2024-AA 5 202349 2024 2024 49 XX 2024-AA 202449XX2024-AA 202449 2025 2023 47 XX 2024-AA 202347XX2024-AA 9 202347 2024 2024 47 XX 2024-AA 202447XX2024-AA 202447 2025 2023 45 XX 2024-AA 202345XX2024-AA 12 202345 2024 2024 45 XX 2024-AA 202445XX2024-AA 202445 2025 2023 44 XX 2024-AA 202344XX2024-AA 13 202344 2024 2024 44 XX 2024-AA 202444XX2024-AA 202444 2025 2023 43 XX 2024-AA 202343XX2024-AA 19 202343 2024 2024 43 XX 2024-AA 202443XX2024-AA 202443 2025 2023 42 XX 2024-AA 202342XX2024-AA 17 202342 2024 2024 42 XX 2024-AA 202442XX2024-AA 202442 2025 2023 41 XX 2024-AA 202341XX2024-AA 14 202341 2024 2024 41 XX 2024-AA 202441XX2024-AA 202441 2025 2023 40 XX 2024-AA 202340XX2024-AA 7 202340 2024 2024 40 XX 2024-AA 202440XX2024-AA 202440 2025 2023 39 XX 2024-AA 202339XX2024-AA 10 202339 2024 2024 39 XX 2024-AA 202439XX2024-AA 202439 2025