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
Ninimbus_jr
Frequent Visitor

Dinamic data bar jumping years

Hi everyone!

 

Im having an issue with a stacked column chart, as bellow:

Ninimbus_jr_0-1642613307523.png



The thing is, i have to show only 3 years, but they must be jumping each 2 years

So, the first graphic it is showing what I need to see, but it has to be dinamic, so, as example, if I select in the slicer the year 2020
the graphic must show 2020, 2018 and 2016

Ninimbus_jr_2-1642613480055.png

 


I set the first graphic static, so im changing it on the filters pane

Do anyone had to do this, or anyone could give me a hint on how to?

For this, I created a simple data set, I tried measures, custom coluns and other stuff, nothing worked so far

Ninimbus_jr_3-1642613571260.png

 

Thanks everyone!!




1 ACCEPTED SOLUTION

I had to go a little further, but thanks anyway!

This is how I solved the problem:

VAR
entrada =
MAX('Calendar'[ano])

VAR tabela =
ADDCOLUMNS(
SUMMARIZE(
Sheet1,
Sheet1[Ano],
"Valor",
CALCULATE(SUM(Sheet1[Valor]),FILTER(Sheet1,Sheet1[Ano]<=entrada && Sheet1[Ano]>= entrada-4))),
"even_odd",
IF(ISEVEN([ano]),TRUE(), FALSE()))

RETURN
IF(ISEVEN(entrada),
SUMX(filter(tabela,[even_odd]==TRUE()),[Valor]),
SUMX(filter(tabela,[even_odd]==FALSE()),[Valor]))

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Ninimbus_jr , Create a separate year table and do not join with the table

 

measure =

var _max = maxx(allselected(Year), Year[Year])

return

calculate(sum(Table[Value]), filter( Table, Table[Year] =_max || Table[Year] =_max -2 || Table[Year] =_max -4))

I had to go a little further, but thanks anyway!

This is how I solved the problem:

VAR
entrada =
MAX('Calendar'[ano])

VAR tabela =
ADDCOLUMNS(
SUMMARIZE(
Sheet1,
Sheet1[Ano],
"Valor",
CALCULATE(SUM(Sheet1[Valor]),FILTER(Sheet1,Sheet1[Ano]<=entrada && Sheet1[Ano]>= entrada-4))),
"even_odd",
IF(ISEVEN([ano]),TRUE(), FALSE()))

RETURN
IF(ISEVEN(entrada),
SUMX(filter(tabela,[even_odd]==TRUE()),[Valor]),
SUMX(filter(tabela,[even_odd]==FALSE()),[Valor]))

HI @Ninimbus_jr,

Thanks for sharing your solution and expressions.😊 I think they will help others who faced similar requirements.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.