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
shahaabz
Frequent Visitor

Count of sales in last three month and last three days in same table.

I am new to power bi . My question is that is it possible to count sale in last three month and last year in the same table view.

Or how many sales has been done in last month and in last last week in the same table . How to display that in one table .

 

 

SectionCount This weekCount This MonthCount This Year
Toy5001500050000
1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @shahaabz,

 

You can refer to below measures:

 

Count of Last Week = 
var currProduct= LASTNONBLANK(Sheet1[Product Name],Sheet1[Product Name])
return
COUNTAX(FILTER(ALL(Sheet1),Sheet1[Product Name]=currProduct&&WEEKNUM(Sheet1[Date])=WEEKNUM(TODAY())-1),Sheet1[Product Name])

 

Count of Last Month = 
var currProduct= LASTNONBLANK(Sheet1[Product Name],Sheet1[Product Name])
return
COUNTAX(FILTER(ALL(Sheet1),Sheet1[Product Name]=currProduct&&and(MONTH(Sheet1[Date])=MONTH(EOMONTH(TODAY(),-1)),YEAR(Sheet1[Date])=YEAR(EOMONTH(TODAY(),-1)))),Sheet1[Product Name])

 

 

Count of Last Year = 
var currProduct= LASTNONBLANK(Sheet1[Product Name],Sheet1[Product Name])
return
COUNTAX(FILTER(ALL(Sheet1),Sheet1[Product Name]=currProduct&&YEAR(Sheet1[Date])=YEAR(TODAY())-1),Sheet1[Product Name])

 

 

Sample:

 

Data table.

Capture.PNG
 

Create a visual to display these result:

Capture2.PNG
 

In addition, if you want to get the sum of amount, you can use sumx function:

 

Sum of Last Year = 
var currProduct= LASTNONBLANK(Sheet1[Product Name],Sheet1[Product Name])
return
SUMX(FILTER(ALL(Sheet1),Sheet1[Product Name]=currProduct&&YEAR(Sheet1[Date])=YEAR(TODAY())-1),Sheet1[Amount])

 

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @shahaabz,

 

You can refer to below measures:

 

Count of Last Week = 
var currProduct= LASTNONBLANK(Sheet1[Product Name],Sheet1[Product Name])
return
COUNTAX(FILTER(ALL(Sheet1),Sheet1[Product Name]=currProduct&&WEEKNUM(Sheet1[Date])=WEEKNUM(TODAY())-1),Sheet1[Product Name])

 

Count of Last Month = 
var currProduct= LASTNONBLANK(Sheet1[Product Name],Sheet1[Product Name])
return
COUNTAX(FILTER(ALL(Sheet1),Sheet1[Product Name]=currProduct&&and(MONTH(Sheet1[Date])=MONTH(EOMONTH(TODAY(),-1)),YEAR(Sheet1[Date])=YEAR(EOMONTH(TODAY(),-1)))),Sheet1[Product Name])

 

 

Count of Last Year = 
var currProduct= LASTNONBLANK(Sheet1[Product Name],Sheet1[Product Name])
return
COUNTAX(FILTER(ALL(Sheet1),Sheet1[Product Name]=currProduct&&YEAR(Sheet1[Date])=YEAR(TODAY())-1),Sheet1[Product Name])

 

 

Sample:

 

Data table.

Capture.PNG
 

Create a visual to display these result:

Capture2.PNG
 

In addition, if you want to get the sum of amount, you can use sumx function:

 

Sum of Last Year = 
var currProduct= LASTNONBLANK(Sheet1[Product Name],Sheet1[Product Name])
return
SUMX(FILTER(ALL(Sheet1),Sheet1[Product Name]=currProduct&&YEAR(Sheet1[Date])=YEAR(TODAY())-1),Sheet1[Amount])

 

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
ankitpatira
Community Champion
Community Champion

@shahaabz You can create three seperate measures under Modelling tab to achieve that for the same table.

Thanx @ankitpatira but as i am new to power bi I dont know how to that.

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.

Top Solution Authors
Top Kudoed Authors