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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
fpennisi17
Helper III
Helper III

Measure that returns an yearly value for each month

In my model, I have a table with Year and Year&Month columns.

For some measures in my dataset, I have a DAX measure that tells me im which Year&Month the measure itself has the last valid value.

 

I want to create a report page in which the user selects a single year and a table with all the months in that year is shown.

For each month, the other column in the table should report the year & month for which a measure has last value, if the year is the same, otherwise the last month of the year.

 

I will try to clarify with an example:

- I have data from 2018 to 2020

- One measure (Production) has its last value on August 2020 (this value is provided with the measure called "Last production Month"

- The user, in the report page, will select a year:

* if the year is 2020, the table should shown all 2020 months (Jan to Dec) in the first column and the month provided by the "Last Production Month" in the second column (in this case, August 2020)

* if the year is 2018 or 2019, the second column should show, instead, "December 2018" or "December 2019" respectively

 

Is there a way to achieve this with a DAX measure?

Thank you

2 REPLIES 2
fpennisi17
Helper III
Helper III

You are right, I wrote a mess. I will try with an example

 

This is my "Year & Month"

Month IDYear
2019-012019
2019-022019
2019-032019
2019-042019
2019-052019
2019-062019
2019-072019
2019-082019
2019-092019
2019-102019
2019-112019
2019-122019
2020-012020
2020-022020
2020-032020
2020-042020
2020-052020
2020-062020
2020-072020
2020-082020
2020-092020
2020-102020
2020-112020
2020-122020

 

I have several timeseries in the model (with 15 minute or daily granularity).

For each timeseries I created a DAX measure that returns the last Year&Month in which that timeseries registered data (e.g.: for the Production of a site, the last data was registered in September 2020, so the measure returns 2020-09.

 

If this is the case, it means that I have data in the whole 2019 and in 2020 until september.

 

So I would like to create a DAX measure (let's call it "Last data"), for the previous timeseries, that returns the following:

 

If the selected year is 2019, the last data for the timeseries in that year is on December, so:

Month IDLast data
2019-012019-12
2019-022019-12
2019-032019-12
2019-042019-12
2019-052019-12
2019-062019-12
2019-072019-12
2019-082019-12
2019-092019-12
2019-102019-12
2019-112019-12
2019-122019-12

 

If the selected year is 2020, the last data for the timeseries in that year is on September, so:

Month IDLast data
2020-012020-09
2020-022020-09
2020-032020-09
2020-042020-09
2020-052020-09
2020-062020-09
2020-072020-09
2020-082020-09
2020-092020-09
2020-102020-09
2020-112020-09
2020-122020-09

 

I hope it is clear now.

Is that possible?

Greg_Deckler
Community Champion
Community Champion

@fpennisi17 Sorry, having trouble following, can you post sample data as text and expected output?


Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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