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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-jayw-msft
Community Support
Community Support

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

2 REPLIES 2
v-jayw-msft
Community Support
Community Support

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors