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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Month on Month Difference

Hi everyone! 

 

I am having trouble digging out a formula to get the month on month difference for each Account Number.

 

My data is structed as below:

 

AccountDateLimitDifference
107/05/2019 €        8,000 
207/05/2019 €        5,000 
307/05/2019 €        1,000 
115/06/2019 €        6,000 
215/06/2019 €        7,000 
315/06/2019 €        3,000 
112/07/2019 €        9,000 
212/07/2019 €        6,000 
312/07/2019 €        5,000 

 

 

My issue is how to find the difference in the limit's for each account and how it differs month to month.

 

Can anyone please help? I would greatly appreciate it.

 

Thank you

 

Water

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Have you tested my solution? If my answer is useful, please accept my reply.Thanks!

Best Regards,

Eads

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

3 REPLIES 3
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

At first, you need to use the following codes in query editor to get a suitable table.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckxOzi/NK1HSUXJJLEkFUj6ZuZlgbmZaWmpRal5yqlKsTrSSIVDIyMDQUtdU1xzIVHjUtEYBCix0DAwMQGJghUa4FZqiKDTGrdAQRSHcajNdQ1M0lWbY7cai0hy75VhUGmO33VzX0AhNpSV227GoNMNuOxaVSIEUCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Account", Int64.Type}, {"Date", type text}, {"Limit", type text}, {"Difference", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Difference"}),
    #"Replaced Value" = Table.ReplaceValue(#"Removed Columns","        ","",Replacer.ReplaceText,{"Limit"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","€","",Replacer.ReplaceText,{"Limit"}),
    #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1",",","",Replacer.ReplaceText,{"Limit"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Replaced Value2",{{"Limit", type number}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type2", {{"Account", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type2", {{"Account", type text}}, "en-US")[Account]), "Account", "Limit", List.Sum),
    #"Added Index" = Table.AddIndexColumn(#"Pivoted Column", "Index", 1, 1)
in
    #"Added Index"

Then you will get a table.2-1.PNG

Now you can create columns to calculate differences.

Compare1to2 =
'Table'[1] - 'Table'[2]
Compare2to3 =
'Table'[2] - 'Table'[3]
Compare1to3 =
'Table'[1] - 'Table'[3]
D1 =
VAR p =
    CALCULATE (
        FIRSTNONBLANK ( 'Table'[1], 1 ),
        FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 )
    )
RETURN
    IF ( p <> BLANK (), 'Table'[1] - p )
D2 =
VAR p =
    CALCULATE (
        FIRSTNONBLANK ( 'Table'[2], 1 ),
        FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 )
    )
RETURN
    IF ( p <> BLANK (), 'Table'[2] - p )
D3 =
VAR p =
    CALCULATE (
        FIRSTNONBLANK ( 'Table'[3], 1 ),
        FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 )
    )
RETURN
    IF ( p <> BLANK (), 'Table'[3] - p )

The final table:

2-2.PNG

Best Regards,

Eads

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Anonymous
Not applicable

Wow!

 

Thank you for such a thorough answer.

 

The solution is too complicated for me to implement but I appreciate your time and effort nonetheless.

 

Thank you

 

Stay Hydrated

Hi @Anonymous ,

 

Have you tested my solution? If my answer is useful, please accept my reply.Thanks!

Best Regards,

Eads

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

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 MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.