Forum Discussion

AltGr9's avatar
AltGr9
Icon for Helper I rankHelper I
7 years ago
Solved

SUM all rows whilst using a filter

Hello,   I have a dataset that looks like this:   Project Date Amount A 2019-06-06 5 A 2019-06-07 10 B 2019-06-05 2 B 2019-06-07 3 C 2019-06-07 2   What I...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Here's how I accomplished this:

    • Created a Date table and related that to your main table
    • Created two project tables, one related to the table and one not

    Use the column from the "DiscConnProject" table for your slicer

    use the project column from the project table for rows on your table

     

    The following measures collect the min and max of the project selected:

    FirstDate of Selected = 
    CALCULATE(
        FIRSTDATE( 'Date'[Date] ),
        FILTER( 
            ALL( Table1),    
            SELECTEDVALUE(DiscConnProject[Project] ) = Table1[Project]
        )
    )
    
    LastDate of Selected = 
    CALCULATE(
        LASTDATE( 'Date'[Date] ),
        FILTER( 
            ALL( Table1),    
            SELECTEDVALUE(DiscConnProject[Project] ) = Table1[Project]
        )
    )

    then a simple total:

    Total Amt = SUM ( Table1[Amount] )

    and the last measure:

    Measure = 
    CALCULATE( 
        [Total Amt],
            FILTER( 
                ALL ('Date'[Date]),
           'Date'[Date] >= [FirstDate of Selected]
           && 'Date'[Date] <= [LastDate of Selected]   
            )
        ,
        ALL( DiscConnProject)
    )