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
Anonymous
Not applicable

dax

I have Month number as [Month], sales as Retailing , document_date and i want to display sales of last to last month. and another measure of sales prior to last to last month. These needs to be displayed in a matrix in with there are some other columns so i can not take month column in column directly. 

MonthRetailing
122
332
112
534
643
254
154
455
365
466
543
364
232
153
465
476

@Uzi2019 

9 REPLIES 9
Anonymous
Not applicable

Hi @Anonymous 
first of all , You have to create calendar table and then connect with your table. That calendar table(Table name is calendar) structure below.

SRIRAGAVENDRAN_0-1700639134246.png

after you will create dax measure.
DAX 1:

LAST 1 MONTH = CALCULATE(SUM(Orders[Sales]),DATEADD('calendar'[Date],-1,MONTH))

DAX 2:

LAST 2 MONTH = CALCULATE(SUM(Orders[Sales]),DATEADD('calendar'[Date],-2,MONTH))

DAX 3:

LAST 3 MONTH = CALCULATE(SUM(Orders[Sales]),DATEADD('calendar'[Date],-3,MONTH))
SRIRAGAVENDRAN_1-1700639280224.png

 

Uzi2019
Super User
Super User

Hi @Anonymous 
Would you please provide the expected output??
dont show the actual data just random data(but correct) in expected output just to get the idea how many columns would be there in matrix visual.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Anonymous
Not applicable

CategorySwing SalesMonth
Aircare377
Aircare308
Aircare289
Aircare2510
Baby Care6537
Baby Care6458
Baby Care6649
Baby Care52010
Fabric & Home Care12107
Fabric & Home Care11678
Fabric & Home Care10199
Fabric & Home Care106710
Fem Care6547
Fem Care6778
Fem Care5469
Fem Care56010
Grooming4367
Grooming5278
Grooming4729
Grooming46010
Hair Care3837
Hair Care2788
Hair Care2689
Hair Care30110
Health Care8417
Health Care9118
Health Care6739
Health Care80410
Oral Care2497
Oral Care1868
Oral Care1879
Oral Care24310
Personal Care (GIL)517
Personal Care (GIL)518
Personal Care (GIL)729
Personal Care (GIL)5110
Personal Care (OS)137
Personal Care (OS)168
Personal Care (OS)199
Personal Care (OS)1410
Skin care207
Skin care308
Skin care289
Skin care5210

if you select 10 th month then i want to display 10th sales as well as 9, 8,7 
expected result for 9th should be 3976 8th should be 4520. I dont want to add month in the matrix.
measures for last month then last to last month and prior to last to last. 3 measures. i do have document_date as date column but if you can do it with just month that would be gr8. @Uzi2019 

Hi @Anonymous 
Please provide data with date column it would be easier to calculate dax.

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Anonymous
Not applicable

Hi @Anonymous 
Please provide the expected output in form of matrix visual. you can calculate in excel share the that table here to understand how you want to see the data. 
how much data will be there when you want to display in table visual.

 

I hope you know what I am asking.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Anonymous
Not applicable

bckg.jpg

i have sales of last year, this year , i have shown last month also but i'am not able to show last 2 last month and before that. these data should change dynamically whenever i select a month then these should change automatically rather than manually entering month for each measure. 

Hi @Anonymous 
Based on your data for 7,8,9,10 as month Number.I have created simple formula
I hope this is what you are looking for 
if you select 10 in slicer then 7,8,9,10 should be calcualted.

Uzi2019_0-1700650224743.png

If I select 9 then 7,8,9 data should be summed up. because you have limited data.
Please create below measure for last 3 months calculation:

Cummuative 1 =
Var N= MAX('Table'[Month])-3
Var A=CALCULATE(SUM('Table'[Swing Sales]),'Table'[Month]>=N && 'Table'[Month]<=MAX('Table'[Month]))

 

I hope this is what you wanted. 
and If you want something like below image then its different calculation!
Based on your selection your measure should change the value.

Uzi2019_1-1700650623252.png

 

 

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Anonymous
Not applicable

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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