cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Dmoreira Frequent Visitor
Frequent Visitor

Previous Month Showing Blank

Hi! I am new to dax and I can't figure out why neither of this measures are working. 

First measure:

PM Line_amt v2 = CALCULATE([Line_amt],PREVIOUSMONTH('Date'[Date]))

Second measure:

PM line_amt = 
SUMX (
    VALUES ( 'Date'[Calendar YearMonthNumber] ),
    VAR OffsetMonths = 1
    VAR MonthDays =
        CALCULATE ( VALUES ( 'Date'[Calendar MonthDays] ) )
    VAR SelectedDays =
        CALCULATE ( DISTINCTCOUNT ( 'Date'[Date] ) )
    VAR PreviousMonthNumber = 'Date'[Calendar YearMonthNumber] - OffsetMonths
    VAR PreviousMonthFull =
        CALCULATE (
            [Line_amt],
            'Date'[Calendar YearMonthNumber] = PreviousMonthNumber,
            ALL ( 'Date' )
        )
    VAR DaysInMonthSelected =
        CALCULATETABLE ( VALUES ( 'Date'[Calendar DayOfMonthNumber] ) )
    VAR PreviousMonthPartial =
        CALCULATE (
            [Line_amt],
            'Date'[Calendar YearMonthNumber] = PreviousMonthNumber,
            DaysInMonthSelected,
            ALL ( 'Date' )
        )
    RETURN
        IF ( MonthDays = SelectedDays, PreviousMonthFull, PreviousMonthPartial )
)

I have an active relationship between fact table and dim date table:Untitled.png

Please help.

1 ACCEPTED SOLUTION

Accepted Solutions
Dmoreira Frequent Visitor
Frequent Visitor

Re: Previous Month Showing Blank

I realized, my measure was working. I just didnt have any date selected, so it wasnt showing previous month. I am closing my request. Thank you for you replay. 

2 REPLIES 2
Community Support Team
Community Support Team

Re: Previous Month Showing Blank

Hi @Dmoreira ,

Why do you say your measure not work?

More details will be much helpful.

If it is convenient, could you share some data sample which could reproduce your scenario and your desired output so that we could help further on it?

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Dmoreira Frequent Visitor
Frequent Visitor

Re: Previous Month Showing Blank

I realized, my measure was working. I just didnt have any date selected, so it wasnt showing previous month. I am closing my request. Thank you for you replay. 

Helpful resources

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.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

PBI Community Highlights

PBI Community Highlights

Check out what's new in the Power BI Community!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 378 members 3,822 guests
Please welcome our newest community members: