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
Anonymous
Not applicable

DAX - for opening and closing column

Hi there

 

In PBI, i have a data table of Month, Batch and Exit numbers setup as below.

 

May I know how can I have:

-a column for Closing, which sequentially minus away (from Batch 1 to 4) the Exit number from an opening number.

-a column for Opening, which takes the last calculated Closing number.

 

Sample output per below.

 

thanks!

 

MonthBatchExitColumn - OpeningColumn - Closing
Jan-1811001000900
Jan-182200900700
Jan-183300700400
Jan-184300400100
1 ACCEPTED SOLUTION
PattemManohar
Community Champion
Community Champion

@Anonymous  Please try this as a new column

 

ColumnClosing = 
VAR _Sum = CALCULATE(SUM(Test194GrpRunningTotal[Exit]),ALLEXCEPT(Test194GrpRunningTotal,Test194GrpRunningTotal[Month]))
VAR _Closing = CALCULATE(SUM(Test194GrpRunningTotal[Exit]),FILTER(Test194GrpRunningTotal,Test194GrpRunningTotal[Batch]<=EARLIER(Test194GrpRunningTotal[Batch]) && Test194GrpRunningTotal[Batch]<>1))
RETURN _Sum-IF(ISBLANK(_Closing),0,_Closing)

Then add another new column for ColumnOpening as below

 

ColumnOpening = Test194GrpRunningTotal[ColumnClosing] + Test194GrpRunningTotal[Exit]

image.png





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

Proud to be a PBI Community Champion




View solution in original post

2 REPLIES 2
PattemManohar
Community Champion
Community Champion

@Anonymous  Please try this as a new column

 

ColumnClosing = 
VAR _Sum = CALCULATE(SUM(Test194GrpRunningTotal[Exit]),ALLEXCEPT(Test194GrpRunningTotal,Test194GrpRunningTotal[Month]))
VAR _Closing = CALCULATE(SUM(Test194GrpRunningTotal[Exit]),FILTER(Test194GrpRunningTotal,Test194GrpRunningTotal[Batch]<=EARLIER(Test194GrpRunningTotal[Batch]) && Test194GrpRunningTotal[Batch]<>1))
RETURN _Sum-IF(ISBLANK(_Closing),0,_Closing)

Then add another new column for ColumnOpening as below

 

ColumnOpening = Test194GrpRunningTotal[ColumnClosing] + Test194GrpRunningTotal[Exit]

image.png





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

Proud to be a PBI Community Champion




Anonymous
Not applicable

thank you @PattemManohar !

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.