Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
jlarques
Helper V
Helper V

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. The question is that I don't want to include any employee that its end date is less than 31/12/2024, becuse this date means that the employee not finish its relationship with the company.

jlarques_1-1732852282064.png

I tried to create this measure, but the result is blank.

jlarques_2-1732852395316.png

How can I do this? 

Thanks to everybody.

 

José Luis 

 

 

1 ACCEPTED SOLUTION
FarhanJeelani
Impactful Individual
Impactful Individual

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.

View solution in original post

2 REPLIES 2
jlarques
Helper V
Helper V

Thank you so much @FarhanJeelani !

your explanation contains important details to understand what was the problem. Now it works and I have my specific calculation for each employee.

 

Thanks again!

 

 

FarhanJeelani
Impactful Individual
Impactful Individual

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.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.