Forum Discussion

jlarques's avatar
jlarques
Icon for Helper V rankHelper V
1 year ago
Solved

Future expenses project

Dear community, I have many rows with start and finish dates. I want to project expenses(cost+salary) for future months. For instance, we are in november and I want to project expenses for december....
  • FarhanJeelani's avatar
    1 year ago

    Hi jlarques ,

    To project expenses for a future month (e.g., December 2024) while excluding employees whose END DATE is earlier than 31/12/2024, you can modify your DAX measure as follows:

    Corrected DAX Measure

    ProjectedExpenses =
    VAR _FechaFin = DATEVALUE("31/12/" & YEAR(TODAY()))
    VAR Result =
        CALCULATE(
            SUM(factPuestos[Cost]) + SUM(factPuestos[Salary]),
            FILTER(
                factPuestos,
                factPuestos[END DATE] >= _FechaFin
            )
        )
    RETURN
        Result

    Explanation:

    1. _FechaFin Calculation:

      • Defines 31/12/2024 dynamically using the current year. Replace YEAR(TODAY()) with a specific year if necessary.
    2. FILTER Logic:

      • Ensures rows are included only if the END DATE is greater than or equal to 31/12/2024.
    3. Summation:

      • Adds the Cost and Salary columns for the filtered rows.
    4. SUM vs. VALUES:

      • Use SUM instead of VALUES to calculate total expenses, as VALUES will return a single value or an error for multiple rows.

    Troubleshooting:

    • Ensure factPuestos[END DATE] is in a proper date format. If it is stored as text, convert it using DATEVALUE.
    • If the measure still returns blank, verify that:
      • There are rows where END DATE >= 31/12/2024.
      • Cost and Salary columns contain numeric values.

    Let me know if you face further issues!

     

    Please accept this as solution if it helps. Appreciate Kudos.