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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
dbiduk
New Member

Comparing Values with Previous not based on Dates

Hi,

 

Relative noobie here.  I have checked many existing posts and videos but I am not getting how to approach the problem.

 

I have 2 tables as below, with one-to-many from LOADS.load to HOLDINGS.load in order to define the Previous Load given a Load.

 

dbiduk_0-1682452547285.png

And this is what I would like to see in a Matrix or Table:

dbiduk_1-1682452619842.png

I realize I need to do something at the Query level (new column or some DAX expression) but I don't understand how I can add a column to my Holdings table that says something like:

 

Previous Value = HOLDINGS.Value where current.Load = LOADS.Previous Load and current.Holding = HOLDINGS.Holding

 

And then calculating the Chg would be easy enough (Calculated column).

 

Please help!

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

Previous period value.pbix

 

Simple enough if the rule of "previous load" persists; even the LOADS table is redundant. (rule of "previous load": the max Load less than current Load)

ThxAlot_0-1682494692800.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

5 REPLIES 5
ThxAlot
Super User
Super User

Previous period value.pbix

 

Simple enough if the rule of "previous load" persists; even the LOADS table is redundant. (rule of "previous load": the max Load less than current Load)

ThxAlot_0-1682494692800.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Even though all solutions posted work, I like this one because I don't have to create the Load table and entries - even though I didn't ask for this.

 

Thanks all for helping me out.

wdx223_Daniel
Super User
Super User

wdx223_Daniel_0-1682482035920.pngwdx223_Daniel_1-1682482056974.png

Total = SUM(HOLDINGS[value])
Chg = VAR _prev=CALCULATE([Total],TREATAS(VALUES(LOADS[previous load]),HOLDINGS[load]),REMOVEFILTERS(LOADS[load])) RETURN DIVIDE([Total]-_prev,_prev)
danextian
Super User
Super User

Hi @dbiduk ,

 

With the given data, create two calculated columns

Previous Load by holding = 
CALCULATE (
    MAX ( 'Table'[Load] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Holding] ),
        'Table'[Load] < EARLIER ( 'Table'[Load] )
    )
)
Previous value by holding = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Holding] ),
        'Table'[Load] = EARLIER ( 'Table'[Previous Load by holding] )
    )
)

 

Use the second column to create a % change measure.

Note: the look you want  for your matrix is not currently achievable out of the box ( will require advanced DAX)

danextian_0-1682480510453.png

Please see attached pbix for reference.

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Actually, this one doesn't need the LOAD table either.  I kinda prefer this one becuase it adds the new data as calculated columns, not measures.  But, again, I am new so what do I know :-).

 

Thanks!!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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