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

reiterate a column to match value and then proceed to a computation

Hello Guys,

I would like to find a solution to make Power Bi perform some computations by taking a previously available value using its rank.

Here is my table. In column Rank, I just got ranks for some variables. In column Max, I just asked to show the maximal Rank for this subgroup. In the last column, I told Power Bi to take the value belonging to the last rank(24) and do some calculations. Now, I want to know how I should do to use the last available value, which is 5.4, and do some calculations, let's imagine 5.4+1, for the rank n23. After getting 6.4, do the same (6.4+1) for the rank 22.

IlliaShliapuhin_0-1672102337590.png

I appreciate your help !

1 ACCEPTED SOLUTION

@IlliaShliapuhin 
Please refer to attached sample file with the solution

1.png

Result = 
VAR C = 0.1
VAR CurrentRank = 'Table'[Rank]
VAR CurrentSubTable = 
    CALCULATETABLE ( 
        'Table', 
        ALLEXCEPT ( 'Table', 'Table'[Group], 'Table'[Subgroup] ) 
    )
VAR T1 = TOPN ( 1, CurrentSubTable, 'Table'[Rank] )
VAR MaxRank = MAXX ( T1, 'Table'[Rank] )
VAR Intag = MAXX ( T1, 'Table'[Intag] )
VAR P1 = MaxRank - CurrentRank
VAR Value1 = ( 1 - C ) ^ P1 * Intag
VAR T2 = FILTER ( CurrentSubTable, 'Table'[Rank] >= CurrentRank && 'Table'[Rank] < MaxRank )
VAR Value2 = 
    SUMX ( 
        T2, 
        VAR P2 = COUNTROWS ( FILTER ( T2, 'Table'[Rank] <= EARLIER ( 'Table'[Rank] ) ) )
        RETURN
            POWER ( 1 - C, P2 - 1 ) * 'Table'[Rank] 
    ) 
RETURN
    Value1 + Value2

View solution in original post

9 REPLIES 9
tamerj1
Super User
Super User

Hi @IlliaShliapuhin 
Please refer to attached sample file. Hope this is what you're looking for.

1.png

Result = 
VAR CurrentRank = 'Table'[Rank]
VAR CurrentSubTable = 
    CALCULATETABLE ( 
        'Table', 
        ALLEXCEPT ( 'Table', 'Table'[Group], 'Table'[Subgroup] ) 
    )
VAR MaxRank = MAXX ( CurrentSubTable, 'Table'[Rank] )
VAR Intag = MAXX ( CurrentSubTable, 'Table'[Intag] )
RETURN
    MaxRank - CurrentRank + Intag

Hi @tamerj1 

I truly appreciate your help but it is not exactly what I need.
The model is ok, but I don't need to increment 1 to each value...
Let's take group 2 subgroup C of your sample. The first step is to get the value in the column Result from column Intag, which is 3.9 => this is what we acheived. But then, I need to use this same value of 3.9 for the next row ranked 4, to calculate my second value : 3.9*(1-.1) = 3.51. Then, for the rank 3,i take the previous value which is 3.51 and do the same : 3.51*(1-.1)
Hope it makes sense,
Is it feasible, you think ?


@IlliaShliapuhin 
Please refer to updated sample file 

1.png

Result = 
VAR C = 0.1
VAR CurrentRank = 'Table'[Rank]
VAR CurrentSubTable = 
    CALCULATETABLE ( 
        'Table', 
        ALLEXCEPT ( 'Table', 'Table'[Group], 'Table'[Subgroup] ) 
    )
VAR T1 = TOPN ( 1, CurrentSubTable, 'Table'[Rank] )
VAR MaxRank = MAXX ( T1, 'Table'[Rank] )
VAR Intag = MAXX ( T1, 'Table'[Value] )
VAR P = MaxRank - CurrentRank
VAR Value1 = ( 1 - C ) ^ P * Intag
VAR T2 = FILTER ( CurrentSubTable, 'Table'[Rank] >= CurrentRank && 'Table'[Rank] < MaxRank )
VAR Value2 = SUMX ( T2, POWER ( 1 - C, P - 1 ) * C * 'Table'[Value] ) 
RETURN
    Value1 + Value2

@tamerj1 

It is powerful what you have done, I will study it but unfortunately, it doesn't respond to my question =(
Could you, please take a look at the table below, I tried to exemplify the needed outcome

IlliaShliapuhin_0-1672152576178.png

 

@IlliaShliapuhin 
Please refer to attached sample file with the solution

1.png

Result = 
VAR C = 0.1
VAR CurrentRank = 'Table'[Rank]
VAR CurrentSubTable = 
    CALCULATETABLE ( 
        'Table', 
        ALLEXCEPT ( 'Table', 'Table'[Group], 'Table'[Subgroup] ) 
    )
VAR T1 = TOPN ( 1, CurrentSubTable, 'Table'[Rank] )
VAR MaxRank = MAXX ( T1, 'Table'[Rank] )
VAR Intag = MAXX ( T1, 'Table'[Intag] )
VAR P1 = MaxRank - CurrentRank
VAR Value1 = ( 1 - C ) ^ P1 * Intag
VAR T2 = FILTER ( CurrentSubTable, 'Table'[Rank] >= CurrentRank && 'Table'[Rank] < MaxRank )
VAR Value2 = 
    SUMX ( 
        T2, 
        VAR P2 = COUNTROWS ( FILTER ( T2, 'Table'[Rank] <= EARLIER ( 'Table'[Rank] ) ) )
        RETURN
            POWER ( 1 - C, P2 - 1 ) * 'Table'[Rank] 
    ) 
RETURN
    Value1 + Value2

Hi @tamerj1 
It is perfect, I am very grateful for your assistance!
Thank you very much, boss! 😃

@IlliaShliapuhin 

Now clear. I'll have a lookout at it tomorrow morning 

IlliaShliapuhin
Frequent Visitor

Hi @FreemanZ ,
Thank you, it works, but in my case I need something more sophisticated, please
Actually there is a formula to apply for my initial value from column Intang. Then, the second value i obtain should be the initial input for my subsequent calculation.
Please look at my screenshot below with the illustrated logic

IlliaShliapuhin_0-1672141182150.png

Many thanks !

FreemanZ
Super User
Super User

hi   @IlliaShliapuhin

try to add a column like this:

Result =
VAR _value = MAX('Table'[MAX])
VAR _max = MAX('Table'[Intang])
RETURN _value + _max - [Rank]

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.