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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Adjust price for each year by a index

Hello everyone, 

I want to show the regulation development for "MONEY" for each year by "INDEX". But I have problem creating a measure that can be shown in a tabel and graph visualisation.

I only have the average "MONEY" for year 2015, and i want to show how the average "MONEY" would be in 2016 by the changes in "INDEX" and again for 2017 and so on.

The adjusted amount in 2016 can be calculated as 100.5 (the index in 2016) divided by 100 (the index in 2015) times the "MONEY" 6130 -> 6130 * 100.5 / 100 = 6160,65.

 

I have a main table:

f_boligP_5-1644309494001.png

 

And a Index table:

f_boligP_6-1644309513964.png

 

The visualisation output i want in Power BI should be looking like this:

f_boligP_4-1644308242382.png

 

 

BI example link: https://drive.google.com/drive/folders/1dnpW0s8UaT5KrzEaHtOOuL72ti8xdbDG?usp=sharing

 

Thank you very much.

1 ACCEPTED SOLUTION

@Anonymous Minor tweaks:

Measure = 
  VAR __Average = AVERAGEX(ALL('DATASET'),[MONEY])
  VAR __EarliestYear = MINX(ALL('INDEX'),[YEAR])
  VAR __EarliestIndex = MAXX(FILTER(ALL('INDEX'),[YEAR]=__EarliestYear),[INDEX])
  VAR __CurrentYear = MAX('INDEX'[YEAR])
  VAR __CurrentIndex = MAXX(FILTER('INDEX',[YEAR]=__CurrentYear ),[INDEX])
RETURN
  __Average * DIVIDE(__CurrentIndex, __EarliestIndex)

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@Anonymous Maybe:

Measure =
  VAR __Sum = SUM('Table1'[MONEY])
  VAR __EarliestYear = MAXX(ALL('Table2'),[YEAR])
  VAR __EarliestIndex = MAXX(FILTER('Table2',[YEAR]=__EarliestYear),[INDEX])
  VAR __CurrentYear = MAX('Table2'[YEAR])
  VAR __CurrentIndex = MAXX(FILTER('Table2',[YEAR]=__CurrentYear ),[INDEX])
RETURN
  __Sum * DIVIDE(__CurrentIndex, __EarliestIndex)

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler thanks for the reply. 

When I'm creating the measure in my sample I get: 

f_boligP_1-1644317583414.png

 

The result only gives me for 2021 (And its actually the 2015 result). I also need 2015, 2016, 2017, 2018, 2019, 2020 prices. 

@Anonymous Minor tweaks:

Measure = 
  VAR __Average = AVERAGEX(ALL('DATASET'),[MONEY])
  VAR __EarliestYear = MINX(ALL('INDEX'),[YEAR])
  VAR __EarliestIndex = MAXX(FILTER(ALL('INDEX'),[YEAR]=__EarliestYear),[INDEX])
  VAR __CurrentYear = MAX('INDEX'[YEAR])
  VAR __CurrentIndex = MAXX(FILTER('INDEX',[YEAR]=__CurrentYear ),[INDEX])
RETURN
  __Average * DIVIDE(__CurrentIndex, __EarliestIndex)

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks @Greg_Deckler it works perfectly !

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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