Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi all,
Your help will be good
I am trying to compare data of two weeks week 39,and week 40 , and am trying to do this:
- do a comparison to see which items occured in week 39 and also week 40, and give it a status "carryover " in a a status collumn
- items that occur in week 39 and not in week 40 give it a status "closed"
- Items that occur in week 40 and not in week 39 give it a status "New"
Table2
category | week # | Status |
a | 39 | |
b | 39 | |
d | 39 | |
a | 40 | |
b | 40 | |
d | 40 | |
E | 40 |
"I am a screen reader"
Solved! Go to Solution.
Hi,
Thank you for sharing your problem. I am assuming you want to do it with dax rather than in power query.
Create a calculated column and write this dax.
use the next code
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTK2VIrViVZKQjBTEEyQAhMDuAIoMwXBdIUyYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [category = _t, #"week #" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"category", type text}, {"week #", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Status", each [a=Table.SelectRows(Source, (x)=> x[category]=[category])[#"week #"], b= if a={"39"} then "New" else if a={"40"} then "closed" else "carryover "][b])
in
#"Added Custom"
result in
Hi @PB10 ,
You can also try this dax
Status =
VAR Week39 = CALCULATETABLE(VALUES('Table'[category]), 'Table'[week #] = 39)
VAR Week40 = CALCULATETABLE(VALUES('Table'[category]), 'Table'[week #] = 40)
RETURN
SWITCH(
TRUE(),
SELECTEDVALUE('Table'[category]) IN Week39 && SELECTEDVALUE('Table'[category]) IN Week40, "carryover",
SELECTEDVALUE('Table'[category]) IN Week39 && NOT SELECTEDVALUE('Table'[category]) IN Week40, "closed",
SELECTEDVALUE('Table'[category]) IN Week40 && NOT SELECTEDVALUE('Table'[category]) IN Week39, "New",
BLANK()
)
It outputs exactly what you described.
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @PB10 ,
You can also try this dax
Status =
VAR Week39 = CALCULATETABLE(VALUES('Table'[category]), 'Table'[week #] = 39)
VAR Week40 = CALCULATETABLE(VALUES('Table'[category]), 'Table'[week #] = 40)
RETURN
SWITCH(
TRUE(),
SELECTEDVALUE('Table'[category]) IN Week39 && SELECTEDVALUE('Table'[category]) IN Week40, "carryover",
SELECTEDVALUE('Table'[category]) IN Week39 && NOT SELECTEDVALUE('Table'[category]) IN Week40, "closed",
SELECTEDVALUE('Table'[category]) IN Week40 && NOT SELECTEDVALUE('Table'[category]) IN Week39, "New",
BLANK()
)
It outputs exactly what you described.
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
use the next code
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTK2VIrViVZKQjBTEEyQAhMDuAIoMwXBdIUyYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [category = _t, #"week #" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"category", type text}, {"week #", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Status", each [a=Table.SelectRows(Source, (x)=> x[category]=[category])[#"week #"], b= if a={"39"} then "New" else if a={"40"} then "closed" else "carryover "][b])
in
#"Added Custom"
result in
Hi,
Thank you for sharing your problem. I am assuming you want to do it with dax rather than in power query.
Create a calculated column and write this dax.
Thanks, I have tried reading on this before but, explanation is with image tables.
I am vision impaired and use a screen reader, so explanations with images not super helpfull
Apologies.
INTERSECT allows you to find commonalities between two sets of data that have the same columns. It will return the rows that match between the two data sets. That would be your "carryover".
EXCEPT can work either way, identifying the items that are no longer there ( "churn" ) when comparing previous to recent data sets, or the items that are "new" when comparing recent to previous data sets.
Your sample data does not include churn items.
Please read about EXCEPT() and INTERSECT(). There is also a pattern article you can follow. https://www.daxpatterns.com/new-and-returning-customers/
Check out the July 2025 Power BI update to learn about new features.