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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
SammyBM
Frequent Visitor

Previous sale month not working

Hello All ,

Here is my DAX measure - that return blank results.. Im trying just to get Previous month sales : 

salePreviousMonth =
VAR _PreviousMonth = PREVIOUSMONTH('Calendar'[MonthYear])
VAR SalesAmount = CALCULATE(
    SUM(Hashavshvet[sales]),
    FILTER(
        Hashavshvet,
        Hashavshvet[SortCodeName] = "test" &&
        Hashavshvet[FullName] = "meals" &&
        Hashavshvet[AccountKey] = "800" && Hashavshvet[MonthYear] = _PreviousMonth
    )
)

RETURN SalesAmount
Pleae Help ! 

1 ACCEPTED SOLUTION

Hi @SammyBM - I have tested the sample data, Can you please try below measure and let us know.

 

salePreviousMonth1 =
CALCULATE(
    SUM(Hashavshvet[sales]),
    PREVIOUSMONTH('Calendar'[MonthYear]),
    Hashavshvet[SortCodeName] = "test",
    Hashavshvet[FullName] = "meals",
    Hashavshvet[AccountKey] = "800"
)

 

rajendraongole1_0-1723970662114.png

 

Hope it helps.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @SammyBM ,

Here is my sample data:

vjunyantmsft_0-1723785587841.png

vjunyantmsft_1-1723785594830.png

 

I don't know if there is a relationship between your Calendar table and the Hashavshvet table, so I used a DAX that works fine with or without the relationship:

salePreviousMonth = 
VAR _PreviousMonth = PREVIOUSMONTH('Calendar'[MonthYear])
VAR SalesAmount = CALCULATE(
    SUM(Hashavshvet[sales]),
    FILTER(
        ALL(Hashavshvet),
        Hashavshvet[SortCodeName] = "test" &&
        Hashavshvet[FullName] = "meals" &&
        Hashavshvet[AccountKey] = "800" && YEAR('Hashavshvet'[MonthYear]) = YEAR(_PreviousMonth) && MONTH('Hashavshvet'[MonthYear]) = MONTH(_PreviousMonth)
    )
)
RETURN SalesAmount

vjunyantmsft_5-1723786456456.png

 

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks Dino , Something is weired. I know how to use time intl formulas, But somthing is getting wrong in my DAX  - I've tried your suggsetion ( both calendar and hashavshvet  connected via Date colum. But yet i can get previous month sales - Here my error : 
"... A table of multiple values was suplied where s single value was expected " 

Hi @SammyBM - I have tested the sample data, Can you please try below measure and let us know.

 

salePreviousMonth1 =
CALCULATE(
    SUM(Hashavshvet[sales]),
    PREVIOUSMONTH('Calendar'[MonthYear]),
    Hashavshvet[SortCodeName] = "test",
    Hashavshvet[FullName] = "meals",
    Hashavshvet[AccountKey] = "800"
)

 

rajendraongole1_0-1723970662114.png

 

Hope it helps.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





rajendraongole1
Super User
Super User

Hi @SammyBM -As per above formaule shared, slight modification as below

 

I hope you already have a calendar table in your model

salePreviousMonth =
VAR _PreviousMonth = PREVIOUSMONTH('Calendar'[Date]) // Assuming 'Date' is your calendar date column
RETURN
CALCULATE(
SUM(Hashavshvet[sales]),
FILTER(
Hashavshvet,
Hashavshvet[SortCodeName] = "test" &&
Hashavshvet[FullName] = "meals" &&
Hashavshvet[AccountKey] = "800" &&
Hashavshvet[Date] IN _PreviousMonth // Ensure that you use the actual date field here
)
)

Hope it works, if still  any please share sample data in text for further analysis.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thank you for the support !
The calendar table is set by month year interval , as the customer only wants to look on monthly data. so the monthyear is date. 
i've tried your solution but is still bringing blank values. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors