cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
alextarki
Helper I
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 

 

 

chart10.jpg

 

Thanks

1 ACCEPTED SOLUTION

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.

View solution in original post

4 REPLIES 4
theDarkPrince
Advocate II
Advocate II

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.

az38
Community Champion
Community Champion

@alextarki  hi

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
LinkedIn

Thanks

 

How can I build the entire previous month value?

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.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors