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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
SuperSusa
Frequent Visitor

DAX - EARLIER - % change one cell down

Hi,

 

I am new to PowerBi and this is my first time posting here. What a fantastic forum! Thank you all for your time and sharing your knowledge, you really help people out there a lot!

 

I would like to generate % change from the actual month to the previous months and have therefore created two  index columns with Power Query and then used the EARLIER command. 

 

Then I found two wys of calculating % change but the problem is the same, the results should be down by one line. Changepercent.PNG

Here is the second formula: 

Changepercent2.PNG

In the forum it seems like there are possibilities to copy the table and then merge with PowerQuery, but in this case it is the position of the DAX output that is causing me trouble. 

 

Any suggestions are very much appreciated, thank you!

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@SuperSusa 
Like this

% Change =
VAR CurrentPrice = 'PQ_Bitumen'[Price]
VAR PreviousPrice =
    MAXX (
        FILTER ( 'PQ_Bitumen', 'PQ_Bitumen'[Index.1] = EARLIER ( 'PQ_Bitumen'[Index] ) ),
        'PQ_Bitumen'[Price]
    )
RETURN
    DIVIDE ( CurrentPrice - PreviousPrice, PreviousPrice )

View solution in original post

6 REPLIES 6
FreemanZ
Super User
Super User

hi @SuperSusa 

try like:

%Change =
VAR _pricepre =
MINX(
    FILTER(
        TableName, 
        TableName[Dato] = EDATE(EARLIER(TableName[Dato]), -1)
    ),
    [Price]
)
RETURN
DIVIDE([Price]-_pricepre, _pricepre)
tamerj1
Super User
Super User

@SuperSusa 
Like this

% Change =
VAR CurrentPrice = 'PQ_Bitumen'[Price]
VAR PreviousPrice =
    MAXX (
        FILTER ( 'PQ_Bitumen', 'PQ_Bitumen'[Index.1] = EARLIER ( 'PQ_Bitumen'[Index] ) ),
        'PQ_Bitumen'[Price]
    )
RETURN
    DIVIDE ( CurrentPrice - PreviousPrice, PreviousPrice )

@tamerj1 this worked perfectly, thank you so much , you saved my day or should I better say my whole week!:)

 

tamerj1
Super User
Super User

Hi @SuperSusa 
Just interchange between Index and Index.1 like

FILTER ( 'Table', 'Table'[Index.1] = EARLIER ( 'Table'[Index] ) ) 

this will retrieve the previous row. Then you can easily calculate the difference then the percentage.

Hi,

 

Thank you for your reply. 

I tried, and it comes close now, but thee values do still not come out right. Since the signs were negative, I converted to positive and vice versa via 0- in front of the equation. 

Changepercent3.PNG

@SuperSusa 

It should be

( CurrentRowPrice - PreviousRowPrice ) / PreviousRowPrice

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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