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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Brookied
Helper I
Helper I

Calculate Cumulative Variance help

Hi Guys,

I have a sticky (for me) dax to work out.  My budget sheet (See below grab. 


I need to knwpo how in PowerBI to work out the **bleep** Variance  Grab one is the data, Grab 2 below is the simple formula 

 

In my Desktop i have a table with the Total(budgeted) Actual Inc but cannot get the Dax for Cumluantve Variance. 

 

Any help at all would be bloody fantastic

cum_var.PNG

 

 

cum_var2.PNG

 

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @Brookied,

 

Suppose the data source imported into Power BI desktop looks like below:

1.PNG

 

First, you should change its structure in Query Editor mode.

let
    Source = Excel.Workbook(File.Contents("C:\Users\v-yulgu\Desktop\Sample Data.xlsx"), null, true),
    #"budget table_Sheet" = Source{[Item="budget table",Kind="Sheet"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(#"budget table_Sheet",{{"Column1", type text}, {"Column2", Int64.Type}, {"Column3", Int64.Type}, {"Column4", Int64.Type}, {"Column5", Int64.Type}, {"Column6", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Column1"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Column1]), "Column1", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Attribute"}),
    #"Added Index" = Table.AddIndexColumn(#"Removed Columns", "Index", 1, 1)
in
    #"Added Index"

2.PNG

 

Based on the new table, then, create calculated column using below formula:

Variance =
'budget table'[Actual] - 'budget table'[Total]

Cumluantve Variance =
CALCULATE (
    SUM ( 'budget table'[Variance] ),
    FILTER (
        'budget table',
        'budget table'[Index] <= EARLIER ( 'budget table'[Index] )
    )
)

Best regards,
Yuliana Gu

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

View solution in original post

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @Brookied,

 

Suppose the data source imported into Power BI desktop looks like below:

1.PNG

 

First, you should change its structure in Query Editor mode.

let
    Source = Excel.Workbook(File.Contents("C:\Users\v-yulgu\Desktop\Sample Data.xlsx"), null, true),
    #"budget table_Sheet" = Source{[Item="budget table",Kind="Sheet"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(#"budget table_Sheet",{{"Column1", type text}, {"Column2", Int64.Type}, {"Column3", Int64.Type}, {"Column4", Int64.Type}, {"Column5", Int64.Type}, {"Column6", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Column1"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Column1]), "Column1", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Attribute"}),
    #"Added Index" = Table.AddIndexColumn(#"Removed Columns", "Index", 1, 1)
in
    #"Added Index"

2.PNG

 

Based on the new table, then, create calculated column using below formula:

Variance =
'budget table'[Actual] - 'budget table'[Total]

Cumluantve Variance =
CALCULATE (
    SUM ( 'budget table'[Variance] ),
    FILTER (
        'budget table',
        'budget table'[Index] <= EARLIER ( 'budget table'[Index] )
    )
)

Best regards,
Yuliana Gu

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.