Forum Discussion

akhaliq7's avatar
akhaliq7
Icon for Post Prodigy rankPost Prodigy
4 years ago
Solved

SHow numeric values based on the latest date

I am creating a sales report and need to display numeric values in my matrix based on the latest weeks figures,now I can't use a basic filter as the old weeks have a last week of 52 but the current year the week will be different

 

my table example

 

sales

 

year              weeknum                  units                  income

2021                 1                              5                          500

2021                 2                              11                        1100

2021                 3                               16                     1600

.................

2021                52                            197                        19700

2022                    1                              4                           400

2022                   2                              11                        1100

2022                 3                                15                        1500

 

display

                     2021                     2022

income          19700                   1500

units               197                       15

 

  • Hi akhaliq7 

    please  use

    Units Last Week =

    CALCULATE ( SUM ( Sales[Units] ), Sales[weeknum] = MAX ( Sales[weeknum] ) )

    same for income. 

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    akhaliq7 Try:

    Units Measure =
      VAR __Year = MAX('Table'[year])
      VAR __Week = MAXX(FILTER('Table',[year]=__Year),[weeknum])
    RETURN
      MAXX(FILTER('Table',[year] = __Year && [weeknum] = __Week),[units])
    
  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Hi akhaliq7 

    please  use

    Units Last Week =

    CALCULATE ( SUM ( Sales[Units] ), Sales[weeknum] = MAX ( Sales[weeknum] ) )

    same for income.