Forum Discussion

AL_Thomas's avatar
AL_Thomas
Frequent Visitor
1 year ago
Solved

DatesYTD inside a Calculate and Filter function, How?

Hi all,    I have created a variable to calculate totals based on selectedvalue. I am new to Power BI, can you tell me what i am doing wrong here in the formula? I am trying to calcuate YTD totals f...
  • AL_Thomas's avatar
    1 year ago

    I think i may have solved the issued by using the calculate inside another calculate function.

     

    SelectedBalance YTD =

    VAR CurrentItem = SELECTEDVALUE(IncomeStatement Dtls)

     

    RETURN

    SWITCH(

        TRUE(),

        CurrentItem = "Net Sales", [Net Sales YTD],

        CurrentItem = "Cost of Sales", [Cost of Sales YTD],

        CurrentItem = "Standard Margin", [Std Margin YTD],

       

        CALCULATE(CALCULATE(

            [Totals],

            FILTER(

                'Income Statement Dtls',

                'Income Statement Dtls'[Category] = CurrentItem

            )

        ),DATESYTD(Calender[Date]))

    )