Forum Discussion
wojbal
4 years agoFrequent Visitor
Calculate difference between values in one table based on column
Hello,
Would you be able to help me resolve the issue where I would like to calculate and show the difference in prices which happened from a week ago (2weeks and 3 weeks) by today and show what is the results for it. Below is the example data.
| Title | Price | Sales | Date | Category | Weeks |
| CDT | 376,33 | 1 | 09.05.2022 | Day-Trips | Today |
| CDT | 376,33 | 1 | 09.05.2022 | Unique-Experiences | Today |
| CDT | 376,33 | 1 | 09.05.2022 | City-Tours-Attraction-Product-Category | Today |
| BMF | 95,41 | 51 | 09.05.2022 | Walking-Tours-Attraction-Product-Category | Today |
| BSS | 37,63 | 16 | 09.05.2022 | Walking-Tours-Attraction-Product-Category | Today |
| BSS | 37,63 | 16 | 09.05.2022 | Cultural-Tours-Attraction-Product-Category | Today |
| BMF | 95,41 | 51 | 09.05.2022 | Art-and-Culture | Today |
| BSS | 37,63 | 16 | 09.05.2022 | Audio-Guided-Tours | Today |
| BSS | 37,63 | 16 | 09.05.2022 | Unique-Experiences | Today |
| BMF | 95,41 | 51 | 09.05.2022 | Kid-Friendly | Today |
| BAT | 75,62 | 575 | 09.05.2022 | Global | Today |
| BAT | 75,62 | 575 | 09.05.2022 | Tours-and-Sightseeing | Today |
| BAT | 75,62 | 575 | 09.05.2022 | Likely-To-Sell-Out-Viator-Market-Driven-Mercha | Today |
| BAT | 75,62 | 575 | 09.05.2022 | Bus-and-Minivan-Tours | Today |
| BAT | 75,62 | 575 | 09.05.2022 | Luxury-Tours | Today |
| BAT | 75,62 | 575 | 09.05.2022 | Food-Wine-and-Nightlife | Today |
| BAT | 75,62 | 575 | 09.05.2022 | Audio-Guided-Tours | Today |
| CDT | 383,68 | 1 | 02.05.2022 | Day-Trips | 1 Week Ago |
| CDT | 383,68 | 1 | 02.05.2022 | Unique-Experiences | 1 Week Ago |
| BMF | 95,44 | 51 | 02.05.2022 | Walking-Tours-Attraction-Product-Category | 1 Week Ago |
| BSS | 38,37 | 16 | 02.05.2022 | Cultural-Tours-Attraction-Product-Category | 1 Week Ago |
| BMF | 95,44 | 51 | 02.05.2022 | Art-and-Culture | 1 Week Ago |
| BSS | 38,37 | 16 | 02.05.2022 | Audio-Guided-Tours | 1 Week Ago |
| BSS | 38,37 | 16 | 02.05.2022 | Unique-Experiences | 1 Week Ago |
| BMF | 95,44 | 51 | 02.05.2022 | Kid-Friendly | 1 Week Ago |
| BAT | 77,09 | 561 | 02.05.2022 | Global | 1 Week Ago |
| BAT | 77,09 | 561 | 02.05.2022 | Tours-and-Sightseeing | 1 Week Ago |
| BAT | 77,09 | 561 | 02.05.2022 | Likely-To-Sell-Out-Viator-Market-Driven-Mercha | 1 Week Ago |
| BAT | 77,09 | 561 | 02.05.2022 | Bus-and-Minivan-Tours | 1 Week Ago |
| BAT | 77,09 | 561 | 02.05.2022 | Luxury-Tours | 1 Week Ago |
| BAT | 77,09 | 561 | 02.05.2022 | Food-Wine-and-Nightlife | 1 Week Ago |
| BAT | 77,09 | 561 | 02.05.2022 | Audio-Guided-Tours | 1 Week Ago |
| CDT | 391,66 | 1 | 25.04.2022 | Day-Trips | 2 Weeks Ago |
| CDT | 391,66 | 1 | 25.04.2022 | Full-day-Tours | 2 Weeks Ago |
| CDT | 391,66 | 1 | 25.04.2022 | Unique-Experiences | 2 Weeks Ago |
| CDT | 391,66 | 1 | 25.04.2022 | City-Tours-Attraction-Product-Category | 2 Weeks Ago |
| BMF | 97,74 | 51 | 25.04.2022 | Walking-Tours-Attraction-Product-Category | 2 Weeks Ago |
| BSS | 39,17 | 16 | 25.04.2022 | Cultural-Tours-Attraction-Product-Category | 2 Weeks Ago |
| BMF | 97,74 | 51 | 25.04.2022 | Art-and-Culture | 2 Weeks Ago |
| BSS | 39,17 | 16 | 25.04.2022 | Audio-Guided-Tours | 2 Weeks Ago |
| BSS | 39,17 | 16 | 25.04.2022 | Unique-Experiences | 2 Weeks Ago |
| BMF | 97,74 | 51 | 25.04.2022 | Kid-Friendly | 2 Weeks Ago |
| BAT | 78,7 | 542 | 25.04.2022 | Tours-and-Sightseeing | 2 Weeks Ago |
| BAT | 78,7 | 542 | 25.04.2022 | Bus-and-Minivan-Tours | 2 Weeks Ago |
| BAT | 78,7 | 542 | 25.04.2022 | Luxury-Tours | 2 Weeks Ago |
| BAT | 78,7 | 542 | 25.04.2022 | Food-Wine-and-Nightlife | 2 Weeks Ago |
| BAT | 78,7 | 542 | 25.04.2022 | Audio-Guided-Tours | 2 Weeks Ago |
| CDT | 397,48 | 1 | 19.04.2022 | Day-Trips | Older |
| CDT | 397,48 | 1 | 19.04.2022 | Unique-Experiences | Older |
| BMF | 97,48 | 51 | 19.04.2022 | Walking-Tours-Attraction-Product-Category | Older |
| BSS | 39,75 | 16 | 19.04.2022 | Walking-Tours-Attraction-Product-Category | Older |
| BSS | 39,75 | 16 | 19.04.2022 | Cultural-Tours-Attraction-Product-Category | Older |
| BMF | 97,48 | 51 | 19.04.2022 | Art-and-Culture | Older |
| BSS | 39,75 | 16 | 19.04.2022 | Audio-Guided-Tours | Older |
| BSS | 39,75 | 16 | 19.04.2022 | Unique-Experiences | Older |
| BMF | 97,48 | 51 | 19.04.2022 | Kid-Friendly | Older |
| BAT | 79,87 | 529 | 19.04.2022 | Tours-and-Sightseeing | Older |
| BAT | 79,87 | 529 | 19.04.2022 | Bus-and-Minivan-Tours | Older |
| BAT | 79,87 | 529 | 19.04.2022 | Luxury-Tours | Older |
| BAT | 79,87 | 529 | 19.04.2022 | Audio-Guided-Tours | Older |
| CDT | 397,48 | 1 | 18.04.2022 | Day-Trips | 3 Weeks Ago |
| CDT | 397,48 | 1 | 18.04.2022 | Unique-Experiences | 3 Weeks Ago |
| BMF | 97,48 | 51 | 18.04.2022 | Walking-Tours-Attraction-Product-Category | 3 Weeks Ago |
| BSS | 39,75 | 16 | 18.04.2022 | Walking-Tours-Attraction-Product-Category | 3 Weeks Ago |
| BSS | 39,75 | 16 | 18.04.2022 | Cultural-Tours-Attraction-Product-Category | 3 Weeks Ago |
| BMF | 97,48 | 51 | 18.04.2022 | Art-and-Culture | 3 Weeks Ago |
| BSS | 39,75 | 16 | 18.04.2022 | Audio-Guided-Tours | 3 Weeks Ago |
| BSS | 39,75 | 16 | 18.04.2022 | Unique-Experiences | 3 Weeks Ago |
| BMF | 97,48 | 51 | 18.04.2022 | Kid-Friendly | 3 Weeks Ago |
| BAT | 79,87 | 529 | 18.04.2022 | Tours-and-Sightseeing | 3 Weeks Ago |
| BAT | 79,87 | 529 | 18.04.2022 | Bus-and-Minivan-Tours | 3 Weeks Ago |
| BAT | 79,87 | 529 | 18.04.2022 | Luxury-Tours | 3 Weeks Ago |
| BAT | 79,87 | 529 | 18.04.2022 | Audio-Guided-Tours | 3 Weeks Ago |
I really appreciate your help,
Thanks!
Hi wojbal ,
Use the following
Todays Price = CALCULATE(SUM(Test[Price]), KEEPFILTERS(Test[Weeks] = "Today"))Price 1 Weeks Ago = CALCULATE(SUM(Test[Price]), KEEPFILTERS(Test[Weeks] = "1 Week Ago"))Price 2 Weeks Ago = CALCULATE(SUM(Test[Price]), KEEPFILTERS(Test[Weeks] = "2 Weeks Ago"))Price 3 Weeks Ago = CALCULATE(SUM(Test[Price]), KEEPFILTERS(Test[Weeks] = "3 Weeks Ago"))And subtract as required.
1 Reply
- davehusMemorable Member
Hi wojbal ,
Use the following
Todays Price = CALCULATE(SUM(Test[Price]), KEEPFILTERS(Test[Weeks] = "Today"))Price 1 Weeks Ago = CALCULATE(SUM(Test[Price]), KEEPFILTERS(Test[Weeks] = "1 Week Ago"))Price 2 Weeks Ago = CALCULATE(SUM(Test[Price]), KEEPFILTERS(Test[Weeks] = "2 Weeks Ago"))Price 3 Weeks Ago = CALCULATE(SUM(Test[Price]), KEEPFILTERS(Test[Weeks] = "3 Weeks Ago"))And subtract as required.