Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Calculate a sum in a table with visual filter

Hello,

i'm trying to calculate sum's for each row of the table (MetaP1 value) below. The values are filtered with the date slicers on the left.

 

 

The data i need to sum is in another table as below:

to summarize, what i want to do is:
for the date slice 01/01/2022 ~ 01/02/2022, get the sum of the [Meta] values of the second table filtered with the [Data] value and for each [Client] in the first table.

Example: table 2:

ClientDateMeta
A01/01/2023100
A02/01/2023100
A03/01/2023100
A04/01/2023100
A05/01/2023100
B01/01/2023100
B02/01/2023100
.........

 

Data range 01/01/2023 to 05/01/2023:
Client A: 500
Client B: 200 + .... but the result appearing in the first table

 

Thank you!

  • Anonymous , You have to create measure for that. Assuming filter on an independent table

     

    //Date1 is independent Date table
    new measure =
    var _max = maxx(allselected(Date1),Date1[Date])
    var _min = minx(allselected(Date1),Date1[Date])
    return
    calculate( sum(Table[Value]), filter('Table', 'Table'[Date] >=_min && 'Table'[Date] <=_max))

     

2 Replies

  • Anonymous , You have to create measure for that. Assuming filter on an independent table

     

    //Date1 is independent Date table
    new measure =
    var _max = maxx(allselected(Date1),Date1[Date])
    var _min = minx(allselected(Date1),Date1[Date])
    return
    calculate( sum(Table[Value]), filter('Table', 'Table'[Date] >=_min && 'Table'[Date] <=_max))

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for the reply!
      It worked like a charm, thank you!