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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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
v-junyant-msft
Community Support
Community Support

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
Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors