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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
leandroduarte
Helper I
Helper I

Index for minimum year and per Item

Dear Colleagues,

 

I'm trying to find a Dax formula build an index to compare teh minimum year and item with the next year figures.

 

Please see below the example and expected results = column Index

yearItemValueIndex = Expected results 
2011A120                                     100For item A = The min should be based on 2011 figures
2012A130                                     108Compare vs. 2011 for item A
2013A110                                       92Compare vs. 2011 for item A
2014A100                                       83Compare vs. 2011 for item A
2015A90                                       75Compare vs. 2011 for item A
2016A120                                     100Compare vs. 2011 for item A
2011B120                                     100For item B = The min should be based on 2011 figures
2012B130                                     108Compare vs. 2011 for item B
2013B110                                       92Compare vs. 2011 for item B
2014B100                                       83Compare vs. 2011 for item B
2015B90                                       75Compare vs. 2011 for item B
2016B120                                     100Compare vs. 2011 for item B

 

I appreciate if you can share some ideas

3 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @leandroduarte ,

 

Few questions to clearly understand what you want to achieve:

- You want to compare the value for an item with the earliest value of the same item (e.g. compare value of item A in 2015 with value of same item A in 2011, A in 2014 vs A in 2011, etc.). Correct ? If not, could you please give more information.

- Do you want to do this in a measure or in a calculated column?

 

If you aim to do it in a calculated column, you could write the following DAX:

VAR CurrentItem = table[Item]
VAR MinYear =
    MINX(
        FILTER( table, table[item] = CurrentItem )
        table[year]
    )

VAR ValueForMinYear =
    MAXX(
        FILTER(
            table,
            table[item] = CurrentItem &&
            table[year] = MinYear
        ),
        table[Value]
    )

RETURN ValueForMinYear

or

RETURN table[Value] - ValueForMinYear

 

Hope it helps. Does it?


Best,

Thomas

View solution in original post

Dear Tomas

 

Yes, it is correct, I want to compare the value for an item with the earliest value of the same item (e.g. compare value of item A in 2015 with value of same item A in 2011, A in 2014 vs A in 2011, etc.).

 

 

In this case I would like to have as measure

 

I tried the expression you informed but it didnt work

View solution in original post

v-kelly-msft
Community Support
Community Support

Hi @leandroduarte ,

 

Could you pls advise how to get the expected result as you provided?

To my understanding,the result should be as below:

year Item Value Index should be  Index = Expected results
2011 A 120 0                                      100
2012 A 130 10                                      108
2013 A 110 -10                                        92
2014 A 100 -20                                        83
2015 A 90 -30                                        75
2016 A 120 0                                      100
2011 B 120 120                                      100
2012 B 130 10                                      108
2013 B 110 -10                                        92
2014 B 100 -20                                        83
2015 B 90 -30                                        75
2016 B 120 0                                      100

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hi @leandroduarte ,

 

Could you pls advise how to get the expected result as you provided?

To my understanding,the result should be as below:

year Item Value Index should be  Index = Expected results
2011 A 120 0                                      100
2012 A 130 10                                      108
2013 A 110 -10                                        92
2014 A 100 -20                                        83
2015 A 90 -30                                        75
2016 A 120 0                                      100
2011 B 120 120                                      100
2012 B 130 10                                      108
2013 B 110 -10                                        92
2014 B 100 -20                                        83
2015 B 90 -30                                        75
2016 B 120 0                                      100

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Anonymous
Not applicable

Hi @leandroduarte ,

 

Few questions to clearly understand what you want to achieve:

- You want to compare the value for an item with the earliest value of the same item (e.g. compare value of item A in 2015 with value of same item A in 2011, A in 2014 vs A in 2011, etc.). Correct ? If not, could you please give more information.

- Do you want to do this in a measure or in a calculated column?

 

If you aim to do it in a calculated column, you could write the following DAX:

VAR CurrentItem = table[Item]
VAR MinYear =
    MINX(
        FILTER( table, table[item] = CurrentItem )
        table[year]
    )

VAR ValueForMinYear =
    MAXX(
        FILTER(
            table,
            table[item] = CurrentItem &&
            table[year] = MinYear
        ),
        table[Value]
    )

RETURN ValueForMinYear

or

RETURN table[Value] - ValueForMinYear

 

Hope it helps. Does it?


Best,

Thomas

Dear Tomas

 

Yes, it is correct, I want to compare the value for an item with the earliest value of the same item (e.g. compare value of item A in 2015 with value of same item A in 2011, A in 2014 vs A in 2011, etc.).

 

 

In this case I would like to have as measure

 

I tried the expression you informed but it didnt work

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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