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

DAX formula help

Please help

I want to calculate opening balance based on released date and completion date

For any date, i want to calculaten opening balance based on below conditions:

https://drive.google.com/drive/folders/1Fgnvl17hLfMKefH338isn3ukaHnmg_qU?usp=sharing 

 

OPENING BAL =

RELEASED DATE <  REPORT DATE 

AND  RELEASED DATE <> BLANK() 
AND
COMPLETION DATE >= REPORT DATE 
OR COMPLETION DATE = BLANK() 

 

SonaSingh123_0-1640190275391.png

 

1 ACCEPTED SOLUTION

Try this as a measure on a table with CALENDAR[Date]:

Opening Balance = 
VAR ReportDate = SELECTEDVALUE ( 'CALENDAR'[Date] )
RETURN
    SUMX (
        FILTER (
            CALCULATETABLE ( DATA, REMOVEFILTERS ( 'CALENDAR' ) ),
            ( DATA[RELEASED DATE] < ReportDate && NOT ( ISBLANK ( DATA[RELEASED DATE] ) ) ) &&
            ( DATA[COMPLETION DATE] >= ReportDate || ISBLANK ( DATA[COMPLETION DATE] ) )
        ),
        DATA[QUANTITY]
    )

AlexisOlson_0-1640194385478.png

View solution in original post

6 REPLIES 6
smpa01
Super User
Super User

@Anonymous  try this

measure =
CALCULATE (
    SUM ( tbl[Quantity] ),
    FILTER ( tbl, tbl[ReleaseDate] < TODAY () || tbl[ReleaseDate] <> BLANK () )
)
    + CALCULATE (
        SUM ( tbl[Quantity] ),
        FILTER (
            tbl,
            tbl[CompletionDate] > TODAY ()
                || tbl[CompletionDate] <> BLANK ()
        )
    )
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

@smpa01 Can you please check below link, both sample data and output added

https://drive.google.com/drive/folders/1Fgnvl17hLfMKefH338isn3ukaHnmg_qU?usp=sharing 

@smpa01 I think your first || should be &&, your last <> should be =, and I don't think you want to separate this into two sums.

 

@Anonymous I think this might be a bit closer:

Opening Balance = 
VAR ReportDate = TODAY () /* Or however this is determined*/
RETURN
    SUMX (
        FILTER (
            Table1,
            ( Table1[ReleaseDate] < ReportDate && NOT ( ISBLANK ( Table1[ReleaseDate] ) ) ) &&
            ( Table1[CompletionDate] >= ReportDate || ISBLANK ( Table1[CompletionDate] ) )
        ),
        Table1[Quantity]
    )
Anonymous
Not applicable

@AlexisOlson 

Can you please check below link, both sample data and output added

https://drive.google.com/drive/folders/1Fgnvl17hLfMKefH338isn3ukaHnmg_qU?usp=sharing 

Try this as a measure on a table with CALENDAR[Date]:

Opening Balance = 
VAR ReportDate = SELECTEDVALUE ( 'CALENDAR'[Date] )
RETURN
    SUMX (
        FILTER (
            CALCULATETABLE ( DATA, REMOVEFILTERS ( 'CALENDAR' ) ),
            ( DATA[RELEASED DATE] < ReportDate && NOT ( ISBLANK ( DATA[RELEASED DATE] ) ) ) &&
            ( DATA[COMPLETION DATE] >= ReportDate || ISBLANK ( DATA[COMPLETION DATE] ) )
        ),
        DATA[QUANTITY]
    )

AlexisOlson_0-1640194385478.png

Anonymous
Not applicable

Thanks @AlexisOlson for the wonderful solution. 

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.