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
rajasekar_o
Helper III
Helper III

opening stock

hi team, i need Help 

i have stock data 

rajasekar_o_1-1702900084009.png

 

with out date filter its shows correct value . if am applay date filter opening Quantity not Show
(as per date 02-04-2019 have opening qty is 19.10) like this am giveing any date opening quantity not show

rajasekar_o_2-1702900107595.png

am used opening quantity calculation

opening quantity =
CALCULATE(
    [rec qty]-[issue qty],
    FILTER(
        ALL('STOCKVALUE'[DOCDATE]),
        'STOCKVALUE'[DOCDATE] + 1 <= MAX('STOCKVALUE'[DOCDATE])
    )
)
 

how to solve this problem.

1 ACCEPTED SOLUTION
danextian
Super User
Super User

hI @rajasekar_o ,

 

This is one of the reasons why, as a good practice, to use a seprate dates table - this simplifies time intelligence calculations. If you don't have one yet you can import or create one in M or DAX (using CALENDAR function). If you already have one and have setup a relationship to your fact table, try this formula

=
CALCULATE (
    [rec qty] - [issue qty],
    FILTER ( ALL ( DatesTable ), DatesTable[Date] < MIN ( DatesTable[Date] ) )
)

 

This tells Power BI to get the running value of [rec qty]-[issue qty] before the date in the current filter context which, based on yoru sample table, is before any of the dates in the Date column. Closing is simply <=MAX ( DatesTable[Date] )

 

If  this doesn't work for you, please post a  sample data that can be copy-pasted (not an image) or sanitized copy of your pbix (confidential data removed). You can post a link to a file in the cloud.

 










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

1 REPLY 1
danextian
Super User
Super User

hI @rajasekar_o ,

 

This is one of the reasons why, as a good practice, to use a seprate dates table - this simplifies time intelligence calculations. If you don't have one yet you can import or create one in M or DAX (using CALENDAR function). If you already have one and have setup a relationship to your fact table, try this formula

=
CALCULATE (
    [rec qty] - [issue qty],
    FILTER ( ALL ( DatesTable ), DatesTable[Date] < MIN ( DatesTable[Date] ) )
)

 

This tells Power BI to get the running value of [rec qty]-[issue qty] before the date in the current filter context which, based on yoru sample table, is before any of the dates in the Date column. Closing is simply <=MAX ( DatesTable[Date] )

 

If  this doesn't work for you, please post a  sample data that can be copy-pasted (not an image) or sanitized copy of your pbix (confidential data removed). You can post a link to a file in the cloud.

 










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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.