Forum Discussion

PierreCrunch's avatar
PierreCrunch
Frequent Visitor
3 years ago
Solved

Calculating measure with multiple conditions (including previous months) for a card

Hello, I want to calculate the sum of bank balances for a specific company (let's call it "Project Company") for the previous month(s) and put the balance in a card(s).  I cannot use a slicer or a t...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi PierreCrunch ,

    I have created a  simple sample, please refer to it to see if it helps you.

    Create columns.

    month = MONTH(Sheet1[date])
    year = YEAR(Sheet1[date])

    Then create measures.

    displays the sum of the balance in November

    Measure =
    VAR _1month =
        MONTH ( EDATE ( TODAY (), -1 ) )
    VAR _yyear =
        YEAR ( EDATE ( TODAY (), -1 ) )
    RETURN
        CALCULATE (
            SUM ( Sheet1[value] ),
            FILTER ( ALL ( Sheet1 ), Sheet1[month] = _1month && Sheet1[year] = _yyear )
        )
    

     

    In you sample , you need to add  Project Company.

    Measure =
    VAR _1month =
        MONTH ( EDATE ( TODAY (), -1 ) )
    VAR _yyear =
        YEAR ( EDATE ( TODAY (), -1 ) )
    RETURN
        CALCULATE (
            SUM ( Sheet1[value] ),
            FILTER ( ALL ( Sheet1 ), Sheet1[month] = _1month && Sheet1[year] = _yyear&&sheet1[Company]="Project Company" )
        )
    

    Pay attention to letter case.

    Measure2 =
    VAR _1month =
        MONTH ( EDATE ( TODAY (), -2 ) )
    VAR _yyear =
        YEAR ( EDATE ( TODAY (), -1 ) )
    RETURN
        CALCULATE (
            SUM ( Sheet1[value] ),
            FILTER ( ALL ( Sheet1 ), Sheet1[month] = _1month && Sheet1[year] = _yyear )
        )
    

     In you sample , you also  need to add  Project Company.

    Measure2 =
    VAR _1month =
        MONTH ( EDATE ( TODAY (), -2 ) )
    VAR _yyear =
        YEAR ( EDATE ( TODAY (), -1 ) )
    RETURN
        CALCULATE (
            SUM ( Sheet1[value] ),
            FILTER ( ALL ( Sheet1 ), Sheet1[month] = _1month && Sheet1[year] = _yyear&& Sheet1[year] = _yyear&&sheet1[Company]="Project Company" )
        )
    

    How to Get Your Question Answered Quickly 

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Polly

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.