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

Simple aggregation

So I have a very basic table

 

Date    Category  

1/1/18  A

1/1/18  B

1/1/18  A

1/2/18  A

1/2/18  D

2/4/18  E

 

and so on

I can get the count of cetegory by Year Month rolled up, but I want the sigle row of just previous month dynamically. Meaning if I'm in Aug, it shows only July data

 

Something like

Year Month  --------  Count

07-2018      ---------- 50

 

Thanks in advance

 

1 ACCEPTED SOLUTION

I'd stil add the date table. Opens up all kinds of options. you can do this dynamically

 

Using Create Table form the modeling window

 

DateDim = CALENDAR(MIN(table[date]),MAX(table(date))

 

Link to your date column and Voila!

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Assuming you have the date table in your model:

 

CALCULATE(COUNT(Table1.Category),DATEADD(Dates[Date],-1,MONTH)

This will alwasy give you the last month count.

 

 

Thanks
Raj

Anonymous
Not applicable

No there is no data tbale in teh model, it is very flat csv file, all the data in a singel sheet.

I'd stil add the date table. Opens up all kinds of options. you can do this dynamically

 

Using Create Table form the modeling window

 

DateDim = CALENDAR(MIN(table[date]),MAX(table(date))

 

Link to your date column and Voila!

Anonymous
Not applicable

Can you try this?

 

CALCULATE(COUNT(Table1.Category),
                       YEAR( Table1[Date]) = YEAR(EOMONTH(TODAY(),-1)) && MONTH( Table1[Date]) = MONTH(EOMONTH(TODAY(),-1))
)
Anonymous
Not applicable

Wouldn't

YEAR( Table1[Date]) = YEAR(EOMONTH(TODAY(),-1)) 

this give me previous year? I'm looking for current year but previous month.

Anonymous
Not applicable

No, This gives the Year of previous month.

Seward12533
Solution Sage
Solution Sage

Try this measure if you want to apply filters and have it show the last month of the filtered months.

 

Last Month Measure = CALCUALTE([MEASURE],FILTER(Date,date[Date]=MAX(date[Date]))

 

This one if you want the last month regardless of any filterss (for date) applied.

 

Last Month Measure = CALCUALTE([MEASURE],ALL(Date]),FILTER(ALL(Date),date[Date]=MAX(date[Date])

 

You can then create table and drag in your YEAR-Month form the DATE Table and then add your Last Month Measure.

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.