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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
JOKA
Advocate I
Advocate I

Create a measure as last value of another measure for the year

Hi!

 

I need your help. I have "Measure A", then I created "Measure B" and finally "Measure C". The problem is Measure B. I need that this measure takes the value of the last month available for Measure A, then divide this value by 12 and then asign the result to the whole year.  

In the following image I show you how I would like to see it:

example.png

The dax is like this:

- Measure A is ok

- Measure B = CALCULATE(DIVIDE([Measure A];12);ALL('Date'[Fiscal Month]);'Date'[Fiscal Month Nr]=7)

Measure C = CALCULATE([Measure B]*[Month Nr])

 

The last month available is Fiscal Month Nr = 7. I am filtering manually this data in Measure B by adding the last filter ('Date'[Fiscal Month Nr]=7), but I need this to be dinamic and change to the following month (number 😎 every time I load new data.

 

I can´t find a way to solve this. I have tried by adding a new column in my Date table to identify the last month with data but it doesn´t work in a calculate function.

 

Does anyone know what can I do? 

 

Thank you!!

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Please try this expression for your measure.  This assumes your Fiscal Month Number column is numeric (you could convert that in the formula if text), and you've made a table visual with Fiscal Month Number, Month, and this measure.

 

Measure C =
VAR maxfiscalmonth =
CALCULATE (
MAX ( Fiscal[FiscalMonthNumber] ),
FILTER (
ALL ( Fiscal[FiscalMonthNumber] ),
NOT ( ISBLANK ( CALCULATE ( [Measure_A] ) ) )
)
)
VAR maxmonthvalue =
CALCULATE (
SUM ( Fiscal[Measure A] ),
ALL ( Fiscal[FiscalMonthNumber] ),
Fiscal[FiscalMonthNumber] = maxfiscalmonth
)
VAR result =
SELECTEDVALUE ( Fiscal[FiscalMonthNumber] ) * maxmonthvalue / 12
RETURN
result

 

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Microsoft Employee
Microsoft Employee

Please try this expression for your measure.  This assumes your Fiscal Month Number column is numeric (you could convert that in the formula if text), and you've made a table visual with Fiscal Month Number, Month, and this measure.

 

Measure C =
VAR maxfiscalmonth =
CALCULATE (
MAX ( Fiscal[FiscalMonthNumber] ),
FILTER (
ALL ( Fiscal[FiscalMonthNumber] ),
NOT ( ISBLANK ( CALCULATE ( [Measure_A] ) ) )
)
)
VAR maxmonthvalue =
CALCULATE (
SUM ( Fiscal[Measure A] ),
ALL ( Fiscal[FiscalMonthNumber] ),
Fiscal[FiscalMonthNumber] = maxfiscalmonth
)
VAR result =
SELECTEDVALUE ( Fiscal[FiscalMonthNumber] ) * maxmonthvalue / 12
RETURN
result

 

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi! 

 

Thank you for your response! I tried this but didn´t work. Here is what I see now ("Measure D" is the one with the new expression):

 

example2.png

 

Measure D =
VAR maxfiscalmonth =
CALCULATE (
MAX ('Date'[Fiscal Month Nr]);
FILTER (
ALL ('Date'[Fiscal Month Nr]);
NOT ( ISBLANK ( CALCULATE ('Measures 1'[Measure A]) ) )
)
)
VAR maxmonthvalue =
CALCULATE (
'Measures 1'[Measure A];
ALL ('Date'[Fiscal Month Nr]);
'Date'[Fiscal Month Nr] = maxfiscalmonth
)
VAR result =
SELECTEDVALUE ('Date'[Fiscal Month Nr]) * maxmonthvalue / 12
RETURN
result
 
 
mahoneypat
Microsoft Employee
Microsoft Employee

I didn't have the Month name in my visual, so I didn't add that column to the All() parts.  If you replace the two All( ) with this, it should work

ALL ('Date'[Fiscal Month Nr], 'Date'[Month])

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Now it works! Thank you for your help!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.