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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
AlexEnergee3
New Member

Sum previews rows in DAX

Hello,

 

this query

 

EVALUATE    
    SELECTCOLUMNS(
        SUMMARIZECOLUMNS(
                    Times[TimeID]
                    , Items[Factor]
                    , OperationOrders[Quantity]
                    , FILTER(Stations, Stations[BillOfResourcesName] = "Bor1")
                    , FILTER(OperationOrderRows, OperationOrderRows[OperationOrderCode] = "OO-1")
                    , FILTER(NATURALINNERJOIN(Machines,Stations), OR (AND (Machines[IsInBound]=True, Stations[Type]=0), Stations[Type]=1))
                    ,"Qty", SUM(Productions201801[Pieces])
                    )
        ,"TimeID", [TimeID]
        ,"Factor" , [Factor]
        ,"QtyPerFactor", [Quantity]-[Qty]*[Factor]
         )
order by [TimeID]

 

return this result

 

TimeID | Factor | QueryPerFactor

0          |   0,635 |  229,365

60        |   0,635 |  229,365

150      |   0,635 |  229,365

210      |   0,635 |  229,365

300      |   0,635 |  229,365

 

I need to obtain in the QtyPerFactor column the value of the QtyPerFactor preview rows minus the Factor column value

 

Than i need this result

 

TimeID | Factor | QueryPerFactor

0          |   0,635 |  229,365

60        |   0,635 |  228,730

150      |   0,635 |  228,095

210      |   0,635 |  227,460

300      |   0,635 |  226,825

ecc...

 

Can anyone help me?

Thanks so much!

 

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@AlexEnergee3,

 

You may add a calculated column as follows.

Column =
MAXX (
    TOPN ( 1, Table1, Table1[TimeID], ASC ),
    Table1[QtyPerFactor] + Table1[Factor]
)
    - SUMX (
        FILTER ( Table1, Table1[TimeID] <= EARLIER ( Table1[TimeID] ) ),
        Table1[Factor]
    )
Community Support Team _ Sam Zha
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-chuncz-msft
Community Support
Community Support

@AlexEnergee3,

 

You may add a calculated column as follows.

Column =
MAXX (
    TOPN ( 1, Table1, Table1[TimeID], ASC ),
    Table1[QtyPerFactor] + Table1[Factor]
)
    - SUMX (
        FILTER ( Table1, Table1[TimeID] <= EARLIER ( Table1[TimeID] ) ),
        Table1[Factor]
    )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.