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
KHSK
Frequent Visitor

Comparing a value across different snapshot weeks in a single table.

I have a snapshot table and I need to compare whether an Oppty ID in the current week is available in the previous week and derive the Oppty amount if it is unavailable in the previous week. Basically comparing the 2 weeks and deriving what is newly added in the current week. I have 2 slicers to select the weeks-one for Previous and the other for Current.

I need a measure which calculates the above logic and gives me the value as $15000000 from the below table.

Appreciate if someone can help me ASAP. Thanks in advance.

Part 1.

Oppty IDOppty AmtSnapshot Week
110000008
210000008
310000008
410000008
510000008
1100000010
2100000010
3100000010
4100000010
5100000010
6300000010
7300000010
8300000010
9300000010
10300000010

 

 

3 ACCEPTED SOLUTIONS
pankajnamekar25
Super User
Super User

Hello @KHSK 

try this measure

 

Newly Added Amount =

VAR PrevWeek =

    SELECTEDVALUE('SnapshotTable'[Snapshot Week], 0) -- From Previous Week slicer

 

VAR CurrWeek =

    SELECTEDVALUE('SnapshotTable (2)'[Snapshot Week], 0) -- From Current Week slicer

 

VAR PrevIDs =

    CALCULATETABLE (

        VALUES('SnapshotTable'[Oppty ID]),

        'SnapshotTable'[Snapshot Week] = PrevWeek

    )

 

VAR CurrTable =

    FILTER (

        'SnapshotTable',

        'SnapshotTable'[Snapshot Week] = CurrWeek &&

        NOT 'SnapshotTable'[Oppty ID] IN PrevIDs

    )

 

RETURN

    SUMX(CurrTable, 'SnapshotTable'[Oppty Amt])

Thanks,
 Pankaj Namekar | LinkedIn

If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

View solution in original post

johnt75
Super User
Super User

You'll need 2 tables to use in the slicers. You can create them like

Current Week = DISTINCT( Ops[Snapshot Week] )

Prev Week = DISTINCT( Ops[Snapshot Week] )

Make sure that these tables are not connected to the main table.

Create a measure like

New Amount =
VAR PrevOps = CALCULATETABLE(
    VALUES(Ops[Oppty ID]),
    TREATAS(
        VALUES('Prev Week'[Snapshot Week]),
        Ops[Snapshot Week]
    )
)
VAR CurrentOps = CALCULATETABLE(
    VALUES(Ops[Oppty ID]),
    TREATAS(
        VALUES('Current Week'[Snapshot Week]),
        Ops[Snapshot Week]
    )
)
VAR NewOps = EXCEPT(
    CurrentOps,
    PrevOps
)
VAR Result = CALCULATE(
    SUM(Ops[Oppty Amt]),
    NewOps,
    TREATAS(
        VALUES('Current Week'[Snapshot Week]),
        Ops[Snapshot Week]
    )
)
RETURN
    Result

View solution in original post

ChiragGarg2512
Solution Sage
Solution Sage

NewOpptyAmount = 
VAR CurrentWeek = 10 # Insert SelectedValue(Current Week Slicer)
VAR PreviousWeek = 8 # Insert SelectedValue(Previous Week Slicer)

VAR CurrentOppties = CALCULATETABLE(
        VALUES(Snapshot[Oppty ID]),
        Snapshot[Snapshot Week] = CurrentWeek
    )

VAR PreviousOppties = CALCULATETABLE(
        VALUES(Snapshot[Oppty ID]),
        Snapshot[Snapshot Week] = PreviousWeek
    )

VAR NewOpptiesOnly = EXCEPT(CurrentOppties, PreviousOppties)

RETURN
CALCULATE(
    SUM(Snapshot[Oppty Amt])
    , Snapshot[Oppty ID] in NewOpptiesOnly
)

Change the column and variable names accordingly.

View solution in original post

6 REPLIES 6
ChiragGarg2512
Solution Sage
Solution Sage

NewOpptyAmount = 
VAR CurrentWeek = 10 # Insert SelectedValue(Current Week Slicer)
VAR PreviousWeek = 8 # Insert SelectedValue(Previous Week Slicer)

VAR CurrentOppties = CALCULATETABLE(
        VALUES(Snapshot[Oppty ID]),
        Snapshot[Snapshot Week] = CurrentWeek
    )

VAR PreviousOppties = CALCULATETABLE(
        VALUES(Snapshot[Oppty ID]),
        Snapshot[Snapshot Week] = PreviousWeek
    )

VAR NewOpptiesOnly = EXCEPT(CurrentOppties, PreviousOppties)

RETURN
CALCULATE(
    SUM(Snapshot[Oppty Amt])
    , Snapshot[Oppty ID] in NewOpptiesOnly
)

Change the column and variable names accordingly.

Thanks, it worked.

johnt75
Super User
Super User

You'll need 2 tables to use in the slicers. You can create them like

Current Week = DISTINCT( Ops[Snapshot Week] )

Prev Week = DISTINCT( Ops[Snapshot Week] )

Make sure that these tables are not connected to the main table.

Create a measure like

New Amount =
VAR PrevOps = CALCULATETABLE(
    VALUES(Ops[Oppty ID]),
    TREATAS(
        VALUES('Prev Week'[Snapshot Week]),
        Ops[Snapshot Week]
    )
)
VAR CurrentOps = CALCULATETABLE(
    VALUES(Ops[Oppty ID]),
    TREATAS(
        VALUES('Current Week'[Snapshot Week]),
        Ops[Snapshot Week]
    )
)
VAR NewOps = EXCEPT(
    CurrentOps,
    PrevOps
)
VAR Result = CALCULATE(
    SUM(Ops[Oppty Amt]),
    NewOps,
    TREATAS(
        VALUES('Current Week'[Snapshot Week]),
        Ops[Snapshot Week]
    )
)
RETURN
    Result
KHSK
Frequent Visitor

Thanks, it worked.

pankajnamekar25
Super User
Super User

Hello @KHSK 

try this measure

 

Newly Added Amount =

VAR PrevWeek =

    SELECTEDVALUE('SnapshotTable'[Snapshot Week], 0) -- From Previous Week slicer

 

VAR CurrWeek =

    SELECTEDVALUE('SnapshotTable (2)'[Snapshot Week], 0) -- From Current Week slicer

 

VAR PrevIDs =

    CALCULATETABLE (

        VALUES('SnapshotTable'[Oppty ID]),

        'SnapshotTable'[Snapshot Week] = PrevWeek

    )

 

VAR CurrTable =

    FILTER (

        'SnapshotTable',

        'SnapshotTable'[Snapshot Week] = CurrWeek &&

        NOT 'SnapshotTable'[Oppty ID] IN PrevIDs

    )

 

RETURN

    SUMX(CurrTable, 'SnapshotTable'[Oppty Amt])

Thanks,
 Pankaj Namekar | LinkedIn

If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

Thanks, it worked.

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