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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
rasputin
New Member

week to week comparison of position id's results showing new and removed position id's

 

In power bi, i would like to figure out a way to compare Position ID's on a week to week basis. The results will be the exact position id's that are new(added) positions and removed positions from the data.  the visuals will show the counts of new and removed positions, along with a second visual which can display the new and removed positions.  The data table with position id's is uploaded into powerbi every wednesday and a source date column is added to identify when the data was uploaded, so every week there is a new source date added.  The data table is not overwritten, it is added to the existing data table.. currently the data table has 6 weeks of data.  Position Id's are a sequence of 8 numbers, all ids are unique.

Thanks in advance for your help!

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @rasputin ,

I created some data:

vyangliumsft_0-1699874300441.png

 

Here are the steps you can follow:

1. Create measure.

Max_ID =
var _maxdate=
MAXX(ALL('Table'),'Table'[Date])
var _week=
WEEKNUM(_maxdate,2)
return
MAXX(
    FILTER(ALL('Table'),
    WEEKNUM('Table'[Date],2) = _week-1&&'Table'[Group]=MAX('Table'[Group])),[Location ID])
comparisons =
IF(
    MAX('Table'[Location ID])<> [Max_ID],1,0)
new_count =
SUMX(
    FILTER(ALLSELECTED('Table'),WEEKNUM('Table'[Date],2)=WEEKNUM(MAX('Table'[Date]),2)),[comparisons])
remove_count =
SUMX(
FILTER(ALLSELECTED('Table'),WEEKNUM('Table'[Date],2)=WEEKNUM(MAX('Table'[Date]),2)&&'Table'[comparisons]=1),[comparisons])
new positions =
IF(
    MAX('Table'[Location ID]) = [Max_ID],MAX('Table'[Location ID]),BLANK())
removed positions =
IF(
    MAX('Table'[Location ID]) <>[Max_ID],[Max_ID],BLANK())

2. Result:

 

vyangliumsft_1-1699874300442.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi  @rasputin ,

I created some data:

vyangliumsft_0-1699874300441.png

 

Here are the steps you can follow:

1. Create measure.

Max_ID =
var _maxdate=
MAXX(ALL('Table'),'Table'[Date])
var _week=
WEEKNUM(_maxdate,2)
return
MAXX(
    FILTER(ALL('Table'),
    WEEKNUM('Table'[Date],2) = _week-1&&'Table'[Group]=MAX('Table'[Group])),[Location ID])
comparisons =
IF(
    MAX('Table'[Location ID])<> [Max_ID],1,0)
new_count =
SUMX(
    FILTER(ALLSELECTED('Table'),WEEKNUM('Table'[Date],2)=WEEKNUM(MAX('Table'[Date]),2)),[comparisons])
remove_count =
SUMX(
FILTER(ALLSELECTED('Table'),WEEKNUM('Table'[Date],2)=WEEKNUM(MAX('Table'[Date]),2)&&'Table'[comparisons]=1),[comparisons])
new positions =
IF(
    MAX('Table'[Location ID]) = [Max_ID],MAX('Table'[Location ID]),BLANK())
removed positions =
IF(
    MAX('Table'[Location ID]) <>[Max_ID],[Max_ID],BLANK())

2. Result:

 

vyangliumsft_1-1699874300442.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

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