cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
agd50
Resolver I
Resolver I

Measure - Count All Data Except previous quarter?

Does anyone know how to change this measure (perhaps a new one) that can do a count excluding the previous quarter? (No YTD)

agd50_0-1694498748132.png

Count of Incident YTD -1Q =
VAR _today =
    TODAY ()
VAR StartDate =
    DATE ( YEAR ( _today ), 1, 1 )
VAR EndDate =
    DATE ( YEAR ( _today ), FLOOR ( MONTH ( _today ) - 1, 3 ) + 1, 1 ) - 1
VAR Results =
    CALCULATE (
        [Count of x],
        DATESBETWEEN ( 'Dim_Calendar'[Date], StartDate, EndDate )
    )
RETURN
    Results
1 ACCEPTED SOLUTION
devesh_gupta
Solution Supplier
Solution Supplier

@agd50 Have you tried this one...

 

over all  = Sum(Sales[Sales Amount])

 

Last Qtr Today = 
var _today = today()
var _max = eomonth(_today, -1*if( mod(Month(_today),3) =0,3,mod(Month(_today),3)))
var _min = eomonth(_max,-3)+1
return 
CALCULATE(Sum(Sales[Sales Amount]) , FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

Then Total other than last qtr =

[Over all] - [Last Qtr Today]

 

In this, you can replace the measure sum with count as you need count.

Also confirm are you using date filter on the page or not cause that can change the solution

View solution in original post

3 REPLIES 3
devesh_gupta
Solution Supplier
Solution Supplier

@agd50 Have you tried this one...

 

over all  = Sum(Sales[Sales Amount])

 

Last Qtr Today = 
var _today = today()
var _max = eomonth(_today, -1*if( mod(Month(_today),3) =0,3,mod(Month(_today),3)))
var _min = eomonth(_max,-3)+1
return 
CALCULATE(Sum(Sales[Sales Amount]) , FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

Then Total other than last qtr =

[Over all] - [Last Qtr Today]

 

In this, you can replace the measure sum with count as you need count.

Also confirm are you using date filter on the page or not cause that can change the solution

devesh_gupta
Solution Supplier
Solution Supplier

Try this if this works for you.

 

Solution 1:

Count of Incident YTD Excluding Prev Quarter =
VAR _today = TODAY()
VAR StartDate = DATE(YEAR(_today), 1, 1)
VAR EndDate = DATE(YEAR(_today), FLOOR(MONTH(_today) - 1, 3) + 1, 1) - 1
VAR PrevQuarterStartDate = DATE(YEAR(_today), FLOOR(MONTH(_today) - 4, 3) + 1, 1)
VAR PrevQuarterEndDate = DATE(YEAR(_today), FLOOR(MONTH(_today) - 1, 3) + 1, 1) - 1
VAR Results =
CALCULATE(
[Count of x],
DATESBETWEEN('Dim_Calendar'[Date], StartDate, EndDate),
NOT DATESBETWEEN('Dim_Calendar'[Date], PrevQuarterStartDate, PrevQuarterEndDate)
)
RETURN Results

 

Solution 2:

Total Sales when there is not filter of slicer

 

over all  = Sum(Sales[Sales Amount])

 

Last Qtr Today = 
var _today = today()
var _max = eomonth(_today, -1*if( mod(Month(_today),3) =0,3,mod(Month(_today),3)))
var _min = eomonth(_max,-3)+1
return 
CALCULATE(Sum(Sales[Sales Amount]) , FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

Then Total other than last qtr =

[Over all] - [Last Qtr Today]

Thanks but I should have clarified I meant without YTD

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors