Forum Discussion

Junaid11's avatar
Junaid11
Helper V
3 years ago
Solved

Subtract the column from a fixed value

Hello, I have a below table: Date Ependiture Budget 1/1/2023 2354 9800 1/2/2023 34   1/3/2023 6786   1/4/2023 345   1/5/2023 57   1/6/2023 35   1/7/2023 34  ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Junaid11 ,

     

    Here is a measure that produces the precise table that you displayed in your question.

    Outcome = 
    VAR currentDate = 
    SELECTEDVALUE('Table'[Date])
    RETURN
        IF(
            HASONEVALUE('Table'[Date]),
            9800
               - CALCULATE(
                    SUM('Table'[Ependiture]),
                    'Table'[Date] <= currentDate,
                    ALLEXCEPT('Table','Table'[Date])
                )
            ,9800 - sum('Table'[Ependiture])
        )
    

     

     The outcome is showed in the below picture.

    There is a similar question which was answered by Chris Mendoza. Thanks for his contribution!
    You can look it up through this link: Solved: Subtract the value by fixed value to get next subt... - Microsoft Fabric Community

     

    Additional Tips:

    In the future, if you have a various range of budgets, you may consider using the following step.

     

    Go to Modeling ---- New Parameters ---- Numeric Range, and enter a range of numbers you would like to use as budget.


    And then change the measure to a new version:

    Outcome = 
    VAR currentDate = 
    SELECTEDVALUE('Table'[Date])
    VAR budget =
    SELECTEDVALUE('Table'[Budget])
    RETURN
        IF(
            HASONEVALUE('Table'[Date]),
            [Parameter Value]
               - CALCULATE(
                    SUM('Table'[Ependiture]),
                    'Table'[Date] <= currentDate,
                    ALLEXCEPT('Table','Table'[Date])
                )
            ,[Parameter Value] - sum('Table'[Ependiture])
        )
    

     

     

    Now the table will change if the parameter value changes.

     

                                                                                                                                                             

    Best Regards,

    Stephen Tao

     

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