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
Jame5_Blonde2
Helper I
Helper I

DAX : A way to rollback pre calculated values (cumulative fact table)

Hi, 

 

I have a fact table with alot of pre-calculated cumulative totals. I need a DAX measure that calculates the value difference between the Time stamps in the right order. The time can be different (this is based when the job that calculates the values are done.) 

My report is based upon Direct Query so i can´t use Power Query solutions. 

 

As of the first three rows below it should be 0 for the first row and 10 second row, 10 third and so forth...

 

rollbacik.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

When this is solved the plot thickens becuse I also have a lot of dimensions I want to slice and dice these new values. Is this possible?

 

rollback2.JPG

2 ACCEPTED SOLUTIONS

@Jame5_Blonde2 

I didn't see the 2nd table, it was not visible at first :). Please share the correct table structure, yes, granularity matters.

If you are satisfied with my answer, please mark it as a solution so others can easily find it.

Don't forget to give KUDOS ? to replies that help answer your questions


Subscribe to ExcelFort: Learn Power BI, Power Query and Excel

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

Hi,

 

#1 Yes! I did simplify my dataset and Fowmy´s measure will indeed work when only  "Time" and "Value" is pre-summerized in the dataset.  


#2 This is my full dataset structure (I call this DATA3). I haven´t yet created a separate data table (but will do this now from the distinct "Time" rows) and test your example. And thank you very much for this link article Measure Totals, The Final Word !

Great stuff, and wish me luck. I´ll keep you posted!

Granularity.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

HI @Jame5_Blonde2,

#1, I think Fowmy's solution is good enough for your requirements, you can use it to accurately extract the values of different timestamps.

#2, Since these values are calculated in measure formula which calculates result will dynamic changes based on its row content.
If you want to do aggregate with these formula results, you need to manually create a variable table to fix the timestamp in specific date ranges you selected and keep the measure result value static. Then you can use iterator functions to apply the second aggregate mode on these fixed variable table records.

Measure Totals, The Final Word  

Sample: apply two-level 'sum' aggregates on measure formula in a select data range.

measure =
VAR selected =
    ALLSELECTED ( Calendar[Date] )
VAR summary =
    SUMMARIZE (
        FILTER ( ALLSELECTED ( Table ), [Date] IN selected),
        [Time],
        "Amount", [Measure]
    )
RETURN
    SUMX ( summary, [Amount] )

Notice: you can change sumx to other iterator functions to use different aggregate mode on the second level. (e.g. averagex, maxx...)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi,

 

#1 Yes! I did simplify my dataset and Fowmy´s measure will indeed work when only  "Time" and "Value" is pre-summerized in the dataset.  


#2 This is my full dataset structure (I call this DATA3). I haven´t yet created a separate data table (but will do this now from the distinct "Time" rows) and test your example. And thank you very much for this link article Measure Totals, The Final Word !

Great stuff, and wish me luck. I´ll keep you posted!

Granularity.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Fowmy
Super User
Super User

@Jame5_Blonde2 

 

Hi,  Use this measure to get the different between current and previous row:

New Value =
VAR _MAx =
    MAX ( DATA3[Time] )
VAR _Date =
    CALCULATE ( MAX ( DATA3[Time] ), FILTER ( ALL ( data3 ), DATA3[Time] < _MAx ) )
VAR _NewVAlue =
    CALCULATE ( MAX ( DATA3[Value] ), DATA3[Time] = _MAx, ALL ( DATA3 ) )
        - CALCULATE ( MAX ( DATA3[Value] ), DATA3[Time] = _Date, ALL ( DATA3 ) )
RETURN
    _NewVAlue

 

If you are satisfied with my answer, please mark it as a solution so others can easily find it.

Don't forget to give KUDOS ? to replies that help answer your questions


Subscribe to ExcelFort: Learn Power BI, Power Query and Excel

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thx for the quick reponse but that didn´t really do the trick. Do we need to modifiy it further?

Could it be becuse of the granularity in the dataset seen in my second picture?

rollback4.JPG

@Jame5_Blonde2 

I didn't see the 2nd table, it was not visible at first :). Please share the correct table structure, yes, granularity matters.

If you are satisfied with my answer, please mark it as a solution so others can easily find it.

Don't forget to give KUDOS ? to replies that help answer your questions


Subscribe to ExcelFort: Learn Power BI, Power Query and Excel

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.