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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.