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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kasife
Helper V
Helper V

last month sales by category

Hi Guys,

How could I calculate the value of last month's sales by category?

I created the below measure, but when I put it in the pie chart, it gives me the total value of the category, and I would like to get only the last month's value

_Total Vendas LM = 
CALCULATE(
    [_Total vendas],
    DATEADD(d_calendario[Date],-1,MONTH))

kasife_2-1686188526220.png

 

Result I would like to get in the graph above: 

 

kasife_1-1686188485630.png

 

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

pls try this

_Total Vendas LM = 
   VAR _toDay= TODAY()
   VAR _StartDate = EOMONTH( _toDay,-1)
   VAR _EndtDate = EOMONTH( _toDay,-2)+1
 RETURN
CALCULATE(
    [_Total vendas],
    d_calendario[Date] >= _StartDate && d_calendario[Date] <=_EndtDate)

View solution in original post

5 REPLIES 5
Ahmedx
Super User
Super User

try this

_Total Vendas LM = 
   VAR _toDay= TODAY()
   VAR _StartDate = EOMONTH( _toDay,-1)
   VAR _EndtDate = EOMONTH( _toDay,-2)+1
 RETURN
CALCULATE(
    [_Total vendas], FILTER(ALL(d_calendario),
    d_calendario[Date] >= _StartDate && d_calendario[Date] <=_EndtDate))
Ahmedx
Super User
Super User

Share sample pbix file to help you

Ahmedx
Super User
Super User

pls try this

_Total Vendas LM = 
   VAR _toDay= TODAY()
   VAR _StartDate = EOMONTH( _toDay,-1)
   VAR _EndtDate = EOMONTH( _toDay,-2)+1
 RETURN
CALCULATE(
    [_Total vendas],
    d_calendario[Date] >= _StartDate && d_calendario[Date] <=_EndtDate)

@Ahmedx  Thank you so much.

It worked, I was just changing the beginning of the month and the end of the month, that's why I was bringing empty.

@Ahmedx It didn't work, it's blank.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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