Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Benx
Helper I
Helper I

Create a Table with current week data and previous week data

Hello all,

 

I have a data source table that contains a weekly snapshot of project statuses. The table udates every Tuesday morning and appends with the latest updates. Each row of data includes a field with the update date.

Here's a simplified view of the source data:

Benx_0-1652464584985.png


Using the source data, I woudl like to create a new table that looks something like this, so I can track and report weekly changes to key project status fields.

Benx_1-1652464749728.png


Does anyone have any suggestions on the best way to tackle this? I've tried a couple solutions in Power Query, and a couple using DAX to create a virtual table, but just can't make it work. Any detailed suggestions you can offer for a Power Query or DAX solution would be much appreciated!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi

On the second pic you missed a ) to close the calculate function before the coma

But it does no explain everything. I have put your table name and fields names in the formula try it because here it still working well.

the new code you can copy

New Table =
VAR step1 =
SUMMARIZE (
stg_jira_product_team_initiatives_hist,
stg_jira_product_team_initiatives_hist[Initiative Key]
)
RETURN
GENERATE (
step1,
VAR issue = [Initiative Key]
VAR maxdateupdate =
CALCULATE (
MAX ( stg_jira_product_team_initiatives_hist[spark_created_date] ),
stg_jira_product_team_initiatives_hist[Initiative Key] = issue
)
VAR previousupdatedate =
CALCULATE (
MAX ( stg_jira_product_team_initiatives_hist[spark_created_date] ),
stg_jira_product_team_initiatives_hist[spark_created_date] < maxdateupdate
)
VAR curstatus =
CALCULATE (
VALUES ( stg_jira_product_team_initiatives_hist[Workflow Status] ),
stg_jira_product_team_initiatives_hist[spark_created_date] = maxdateupdate
)
VAR prevstatus =
CALCULATE (
VALUES ( stg_jira_product_team_initiatives_hist[Workflow Status] ),
stg_jira_product_team_initiatives_hist[spark_created_date] = previousupdatedate
)
VAR curtarget =
CALCULATE (
MAX ( stg_jira_product_team_initiatives_hist[IP Target Delivery Date] ),
stg_jira_product_team_initiatives_hist[spark_created_date] = maxdateupdate
)
VAR prevtarget =
CALCULATE (
MAX ( stg_jira_product_team_initiatives_hist[IP Target Delivery Date] ),
stg_jira_product_team_initiatives_hist[spark_created_date] = previousupdatedate
)
VAR curryg =
CALCULATE (
VALUES ( stg_jira_product_team_initiatives_hist[R/Y/G] ),
stg_jira_product_team_initiatives_hist[spark_created_date] = maxdateupdate
)
VAR prevryg =
CALCULATE (
VALUES ( stg_jira_product_team_initiatives_hist[R/Y/G] ),
stg_jira_product_team_initiatives_hist[spark_created_date] = previousupdatedate
)
RETURN
ROW (
"Update Date", maxdateupdate,
"Previous Update Date", previousupdatedate,
"Currenty Status", curstatus,
"Previous Status", prevstatus,
"Status change", IF ( curstatus = prevstatus, "No", "Yes" ),
"Current Target deliver Date", curtarget,
"Previous Target deliver Date", prevtarget,
"Target change", IF ( curtarget = prevtarget, "No", "Yes" ),
"Current R/Y/G Status", curryg,
"Previous R/Y/G Status", prevryg,
"R/Y/G change", IF ( curryg = prevryg, "No", "Yes" )
)
)

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi

On the second pic you missed a ) to close the calculate function before the coma

But it does no explain everything. I have put your table name and fields names in the formula try it because here it still working well.

the new code you can copy

New Table =
VAR step1 =
SUMMARIZE (
stg_jira_product_team_initiatives_hist,
stg_jira_product_team_initiatives_hist[Initiative Key]
)
RETURN
GENERATE (
step1,
VAR issue = [Initiative Key]
VAR maxdateupdate =
CALCULATE (
MAX ( stg_jira_product_team_initiatives_hist[spark_created_date] ),
stg_jira_product_team_initiatives_hist[Initiative Key] = issue
)
VAR previousupdatedate =
CALCULATE (
MAX ( stg_jira_product_team_initiatives_hist[spark_created_date] ),
stg_jira_product_team_initiatives_hist[spark_created_date] < maxdateupdate
)
VAR curstatus =
CALCULATE (
VALUES ( stg_jira_product_team_initiatives_hist[Workflow Status] ),
stg_jira_product_team_initiatives_hist[spark_created_date] = maxdateupdate
)
VAR prevstatus =
CALCULATE (
VALUES ( stg_jira_product_team_initiatives_hist[Workflow Status] ),
stg_jira_product_team_initiatives_hist[spark_created_date] = previousupdatedate
)
VAR curtarget =
CALCULATE (
MAX ( stg_jira_product_team_initiatives_hist[IP Target Delivery Date] ),
stg_jira_product_team_initiatives_hist[spark_created_date] = maxdateupdate
)
VAR prevtarget =
CALCULATE (
MAX ( stg_jira_product_team_initiatives_hist[IP Target Delivery Date] ),
stg_jira_product_team_initiatives_hist[spark_created_date] = previousupdatedate
)
VAR curryg =
CALCULATE (
VALUES ( stg_jira_product_team_initiatives_hist[R/Y/G] ),
stg_jira_product_team_initiatives_hist[spark_created_date] = maxdateupdate
)
VAR prevryg =
CALCULATE (
VALUES ( stg_jira_product_team_initiatives_hist[R/Y/G] ),
stg_jira_product_team_initiatives_hist[spark_created_date] = previousupdatedate
)
RETURN
ROW (
"Update Date", maxdateupdate,
"Previous Update Date", previousupdatedate,
"Currenty Status", curstatus,
"Previous Status", prevstatus,
"Status change", IF ( curstatus = prevstatus, "No", "Yes" ),
"Current Target deliver Date", curtarget,
"Previous Target deliver Date", prevtarget,
"Target change", IF ( curtarget = prevtarget, "No", "Yes" ),
"Current R/Y/G Status", curryg,
"Previous R/Y/G Status", prevryg,
"R/Y/G change", IF ( curryg = prevryg, "No", "Yes" )
)
)

Thanks again @Anonymous ! I was able to drop your new code version in, and got the expected results! You are my hero for today!

Anonymous
Not applicable

Hi Benx, No problem happy for you. Have a nice day

Anonymous
Not applicable

Hello,

 

I have created a table==> Feuil1

JamesFr06_0-1652528588262.png

and then I create a new table in Pwbi

JamesFr06_1-1652528650153.png

Try it and tell me if it works.

@Anonymous Thanks so much for providing this example. I really appreciate your efforts! I have tried to implement it this morning, but I'm running into a few errors:

First, it doesn't like the IF expressions for the Change columns:

Benx_0-1652720866393.png

When I comment those lines out, I then get a error in line 16:

Benx_1-1652720968202.png

Any thoughts on what's going on?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors