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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.