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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
joseolima
Frequent Visitor

Add the amount from the previous month to the following month, depending on the status.

Add the amount from the previous month to the following month, depending on the status.
Example: status = "OPERATE" and the month selected is greater than the current month, add 740 to the value of the previous month. 

joseolima_0-1715882600267.png

 

1 ACCEPTED SOLUTION
mh2587
Super User
Super User

Amount with Status = //Try this
VAR CurrentMonth = SELECTEDVALUE('Calendar'[Month])
VAR PreviousMonthAmount = CALCULATE(SUM('Table'[Amount]), 'Calendar'[Month] = CurrentMonth - 1)
VAR CurrentStatus = SELECTEDVALUE('Table'[Status])

RETURN
    IF(
        CurrentStatus = "OPERATE" && CurrentMonth > MONTH(TODAY()),
        PreviousMonthAmount + 740,
        PreviousMonthAmount
    )

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



View solution in original post

3 REPLIES 3
joseolima
Frequent Visitor

Thanks for responding, but it didn't work.

Your code added 740 to the previous  month value, but it repeats the same value in all subsequent months.

I want it to add 740 to the previous month's value, if status = "operarate".
Example:
May: 59,225.97
June: 59,965.97
July: 60,705.97

joseolima_0-1715887928906.png

 



Amount with Status = //Check this one
VAR CurrentMonth = SELECTEDVALUE('Calendar'[Month])
VAR PreviousMonthAmount = 
                        CALCULATE(SUM('Table'[Amount]),
                            FILTER(ALL('Calendar'),'Calendar'[Month] < CurrentMonth))
VAR CurrentStatus = SELECTEDVALUE('Table'[Status])

RETURN
    IF(
        CurrentStatus = "OPERATE" && CurrentMonth > MONTH(TODAY()),
        PreviousMonthAmount + 740,
        PreviousMonthAmount
    )

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



mh2587
Super User
Super User

Amount with Status = //Try this
VAR CurrentMonth = SELECTEDVALUE('Calendar'[Month])
VAR PreviousMonthAmount = CALCULATE(SUM('Table'[Amount]), 'Calendar'[Month] = CurrentMonth - 1)
VAR CurrentStatus = SELECTEDVALUE('Table'[Status])

RETURN
    IF(
        CurrentStatus = "OPERATE" && CurrentMonth > MONTH(TODAY()),
        PreviousMonthAmount + 740,
        PreviousMonthAmount
    )

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Carousel June 2024

Check out the June 2024 Power BI update to learn about new features.

2
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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