cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
prasy14 Regular Visitor
Regular Visitor

Current Year Previous Month DAX

Hello All,

 

 

I am not getting correct t calculated value for previous Month column , For example in below screen shot CM sales for March =3,881,693. in PM Sales column of April month i am expecting 3,881,693.

CM Sales = CALCULATE(SUM('sales'[salesamt]), bcalendar[byear]= YEAR(TODAY()))-- Current Year Sales by month

PM Sales = CALCULATE (SUM('sales'[salesamt]),PREVIOUSMONTH(bcalendar[bdate]), bcalendar[biyear]= YEAR(TODAY())) ---Current Year Previous Month Sales

 

 

 CMVSPM.PNG

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yulgu-msft Super Contributor
Super Contributor

Re: Current Year Previous Month DAX

Hi @prasy14,

 

Please try this:

PM Sales =
CALCULATE (
    SUM ( 'Sales'[SalesAmount] ),
    FILTER (
        ALLSELECTED ( 'bcalendar' ),
        'bcalendar'[bdate].[MonthNo]
            = MONTH ( MAX ( 'bcalendar'[bdate] ) ) - 1
            && 'bcalendar'[byear] = YEAR ( TODAY () )
    )
)

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
BILASolution Established Member
Established Member

Re: Current Year Previous Month DAX

Hi @prasy14

 

This could be useful for you

 

https://1drv.ms/f/s!AuU-Ye8UGM4Rko0xvebM1ZQ7ZZhDeg

 

 

mattbrice Senior Member
Senior Member

Re: Current Year Previous Month DAX

You can try:

 

PM Sales = CALCULATE ( [CM Sales],PREVIOUSMONTH(bcalendar[bdate]) ) ---Current Year Previous Month Sales

Though if it were me, i'd have a 'Year' slicer, to make it easier.

 

 

prasy14 Regular Visitor
Regular Visitor

Re: Current Year Previous Month DAX

Hello @mattbrice,

 

i have to display Current Year,Last Year, LLY,LLLY by months as well that is reason i am not using year slicer.

the code which you have provided is giving me blank values.

prasy14 Regular Visitor
Regular Visitor

Re: Current Year Previous Month DAX

Hi @BILASolution,

 

Thanks for PBIX file, I still get blank values when i use the DAX and I do have same relationship between the tables as yours

 

BILASolution Established Member
Established Member

Re: Current Year Previous Month DAX

@prasy14
Is possible you can send me your pbix file to find a better solution?
likesilverfrog@hotmail.com
mattbrice Senior Member
Senior Member

Re: Current Year Previous Month DAX

Does your 'bcalendar' table include dates for the prior month? prior year? 

v-yulgu-msft Super Contributor
Super Contributor

Re: Current Year Previous Month DAX

Hi @prasy14,

 

Please try this:

PM Sales =
CALCULATE (
    SUM ( 'Sales'[SalesAmount] ),
    FILTER (
        ALLSELECTED ( 'bcalendar' ),
        'bcalendar'[bdate].[MonthNo]
            = MONTH ( MAX ( 'bcalendar'[bdate] ) ) - 1
            && 'bcalendar'[byear] = YEAR ( TODAY () )
    )
)

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 55 members 1,445 guests
Please welcome our newest community members: