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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
verdentum
New Member

Display 1st year data in months and later data to be displayed in years

Hi Everyone,

Requirement is to Display 1st year data in months and from 2nd year onwards data to be displayed in years as shown in below

verdentum_0-1642868892653.png

It should have the ability to change dynamically. Suppose, if i choose march 2020, from march 2020 to Apr 2021 to be display as individual months and the remaining to be displayed as 2021-2022 Like this.

 

Thanks in Advance

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @verdentum ,

 

You will need to create a dimension table. Since you didn't share any date, I created a demo based on my own understanding. Hope it can help you.

Dim table:

1.PNG

Add a yearmonth column to the fact table, then create the Slicer table based on it.

 

slicer = DISTINCT('Table'[yearmonth])

 

 Create measures to get values based on yearmonth.

 

month_value = CALCULATE(SUM('Table'[value]),FILTER(ALL('Table'),'Table'[yearmonth]=SELECTEDVALUE(Dim[x-axis])))

year_value = CALCULATE(SUM('Table'[value]),FILTER(ALL('Table'),LEFT('Table'[yearmonth],4)=SELECTEDVALUE(Dim[x-axis])&&'Table'[yearmonth]>SELECTEDVALUE(slicer[yearmonth])))

_value = IF(SELECTEDVALUE(Dim[type])="month",[month_value],[year_value])

 

At last, create a measure and add it to visual.

 

Measure = IF((SELECTEDVALUE(Dim[x-axis])>=SELECTEDVALUE(slicer[yearmonth])&&SELECTEDVALUE(Dim[x-axis])<FORMAT(EDATE(DATE(LEFT(SELECTEDVALUE(slicer[yearmonth]),4),RIGHT(SELECTEDVALUE(slicer[yearmonth]),2),1),12),"YYYYMM"))||SELECTEDVALUE(Dim[type])="year",_value,blank())

 

Pbix as attached.

 

Best Regards,

Jay

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @verdentum ,

 

You will need to create a dimension table. Since you didn't share any date, I created a demo based on my own understanding. Hope it can help you.

Dim table:

1.PNG

Add a yearmonth column to the fact table, then create the Slicer table based on it.

 

slicer = DISTINCT('Table'[yearmonth])

 

 Create measures to get values based on yearmonth.

 

month_value = CALCULATE(SUM('Table'[value]),FILTER(ALL('Table'),'Table'[yearmonth]=SELECTEDVALUE(Dim[x-axis])))

year_value = CALCULATE(SUM('Table'[value]),FILTER(ALL('Table'),LEFT('Table'[yearmonth],4)=SELECTEDVALUE(Dim[x-axis])&&'Table'[yearmonth]>SELECTEDVALUE(slicer[yearmonth])))

_value = IF(SELECTEDVALUE(Dim[type])="month",[month_value],[year_value])

 

At last, create a measure and add it to visual.

 

Measure = IF((SELECTEDVALUE(Dim[x-axis])>=SELECTEDVALUE(slicer[yearmonth])&&SELECTEDVALUE(Dim[x-axis])<FORMAT(EDATE(DATE(LEFT(SELECTEDVALUE(slicer[yearmonth]),4),RIGHT(SELECTEDVALUE(slicer[yearmonth]),2),1),12),"YYYYMM"))||SELECTEDVALUE(Dim[type])="year",_value,blank())

 

Pbix as attached.

 

Best Regards,

Jay

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. 

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.