cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Helper I

## Value of previous month YYYYMM

Dear All,

I have the following task that I kindly ask you to help me with :

column YYYYMM , values across months

Column YYYYMM is separated from date.

I want to calculate the value of previous month YYYYMM-1 and show it on the chart

PREVIOUS month doesnt help me as its based on date

Thanks

1 ACCEPTED SOLUTION
Community Support

HI @alextarki,

You can try this measure formula if it meets your requirement:

``````Measure =
VAR currYM =
MAX ( Table[YearMonth] )
VAR prevDate =
DATE ( LEFT ( currYM, 4 ), RIGHT ( currYM, 2 ) - 1, 1 )
VAR prevYM =
YEAR ( prevDate ) * 100
+ MONTH ( prevDate )
RETURN
CALCULATE (
SUM ( Table[Amount] ),
FILTER ( ALLSELECTED ( Table ), [YearMonth] = prevYM )
)
``````

Regards,

Xiaoxin Sheng

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

Did this work for anyone ? I have tried the suggested measure definition exactly but still getting BLANKs for all the months. Been searching about this for a couple of days now. I am unabe to use PREVIOUSMONTH() becasue I do not have a proper date column with contiguous dates.

Community Champion

previous month you can find as

``DATE(LEFT([Column], 4), RIGHT([Column], 2)-1, 1)``

do not hesitate to give a kudo to useful posts and mark solutions as solution
Helper I

Thanks

How can I build the entire previous month value?

Community Support

HI @alextarki,

You can try this measure formula if it meets your requirement:

``````Measure =
VAR currYM =
MAX ( Table[YearMonth] )
VAR prevDate =
DATE ( LEFT ( currYM, 4 ), RIGHT ( currYM, 2 ) - 1, 1 )
VAR prevYM =
YEAR ( prevDate ) * 100
+ MONTH ( prevDate )
RETURN
CALCULATE (
SUM ( Table[Amount] ),
FILTER ( ALLSELECTED ( Table ), [YearMonth] = prevYM )
)
``````

Regards,

Xiaoxin Sheng

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

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors