cancel
Showing results for
Did you mean:
Highlighted
Frequent Visitor

## DAX HELP

I want to create Previous month sales measure. so i created Latest month and previous month measures.

But when i create final measure to calculate sales for Previous month i get blank values

Below are the measures

LATESTMONTH = CALCULATE(MAX('Time'[Month Num]),'Time'[CurrMonthFlag] = "Y")
ans)8

Previous Month = latestmonth -1
ans)7

PM Ship Order Count =
CALCULATE([Ship Order Count],FILTER('Time', 'Time'[Month Num] = [PreviousMonth]))

Prathy

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft

## Re: DAX HELP

``````LATESTMONTH = CALCULATE(MAX('Time'[Month Num]),ALL('Time'),'Time'[CurrMonthFlag] = "Y")
PM Ship Order Count =
CALCULATE([Ship Order Count],FILTER(ALL('Time'), 'Time'[Month Num] = [PreviousMonth]))``````

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

Best Regards,

Dedmon Dai

3 REPLIES 3
Highlighted
Super User IV

## Re: DAX HELP

@pmadam , You can use time intelligence with a date calendar

``````MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
Last month value =  CALCULATE(sum('table'[total hours value]),previousmonth('Date'[Date]))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Next month value =  CALCULATE(sum('table'[total hours value]),nextmonth('Date'[Date]))

diff = [MTD Sales]-[last MTD Sales]
diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])``````

https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...

Proud to be a Super User!

Highlighted
Super User IV

## Re: DAX HELP

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.

That said, You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

---------------------------------------

##### I have a NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Proud to be a Super User!

Highlighted
Microsoft

## Re: DAX HELP

``````LATESTMONTH = CALCULATE(MAX('Time'[Month Num]),ALL('Time'),'Time'[CurrMonthFlag] = "Y")
PM Ship Order Count =
CALCULATE([Ship Order Count],FILTER(ALL('Time'), 'Time'[Month Num] = [PreviousMonth]))``````

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

Best Regards,

Dedmon Dai

Announcements

#### Power Platform Community Conference

Check out the on demand sessions that are available now!

#### Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

#### Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors