cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Syndicate_Admin
Administrator
Administrator

How to assign the last value of a month to the first value in the following month

Capture.PNG

This is my table, I want a customer's closing stock value for a given month to be assigned to the initial stock for the following month.

example: 12/31/2020 value is 18079, I want this to appear on 1/4/2021, but what I have is 34984.

Is there any way to do this, pls help your urgent

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

Hi @Syndicate_Admin,

You can try to use the following measure expression if it meets your requirement:

Measure =
VAR currDate =
    MAX ( Table[Date] )
VAR minDateCM =
    //min date of current month
    CALCULATE (
        MIN ( Table[Date] ),
        FILTER (
            ALLSELECTED ( Table ),
            YEAR ( [Date] ) = YEAR ( currDate )
                && MONTH ( [Date] ) = MONTH ( currDate )
        )
    )
VAR maxDatePM =
    //max date of previous month
    CALCULATE (
        MAX ( Table[Date] ),
        FILTER (
            ALLSELECTED ( Table ),
            [Date] < DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 )
        )
    )
RETURN
    IF (
        currDate = minDateCM,
        LOOKUPVALUE ( Table[Value], Table[Date], maxDatePM ),
        SUM ( Table[Value] )
    )

If the above not help, please share some dummy data with raw schema and expected result to test.

How to Get Your Question Answered Quickly

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @Syndicate_Admin,

You can try to use the following measure expression if it meets your requirement:

Measure =
VAR currDate =
    MAX ( Table[Date] )
VAR minDateCM =
    //min date of current month
    CALCULATE (
        MIN ( Table[Date] ),
        FILTER (
            ALLSELECTED ( Table ),
            YEAR ( [Date] ) = YEAR ( currDate )
                && MONTH ( [Date] ) = MONTH ( currDate )
        )
    )
VAR maxDatePM =
    //max date of previous month
    CALCULATE (
        MAX ( Table[Date] ),
        FILTER (
            ALLSELECTED ( Table ),
            [Date] < DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 )
        )
    )
RETURN
    IF (
        currDate = minDateCM,
        LOOKUPVALUE ( Table[Value], Table[Date], maxDatePM ),
        SUM ( Table[Value] )
    )

If the above not help, please share some dummy data with raw schema and expected result to test.

How to Get Your Question Answered Quickly

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

amitchandak
Super User IV
Super User IV

@Syndicate_Admin ,

With help from the date table, try openingbalancemonth

openingbalancemonth(Sum('Table'[Value]), Date[Date])

 

refer my video : https://youtu.be/6lzYOXI5wfo?t=117



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Top Solution Authors
Top Kudoed Authors