Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Laocsulak
Helper I
Helper I

Sales of the last quarter when using slicer by day of the month

Hello,

I have created a measure that show the sales of the last quarter and works fine, but when I use a slicer to filter by the number day of the month it keeps showing the sales of the entire month. Does anyone know how to adapt the measure to fix this?

 

Example:

This shows correctly the sales of the last quarter

Laocsulak_1-1673968894091.png

 

But for example if I filter to see the sales for just the first 10 days for every month of every quarter, it keeps showing the same information in the sales in the last quarter, and that's not correct.

Laocsulak_2-1673968915984.png

Measure craeted:

Sales LQ =
VAR __PREV_QUARTER =
 CALCULATE ( [total sales] , PREVIOUSQUARTER(Calendario[Date]) )
RETURN
 IF (
 ISBLANK ( __PREV_QUARTER ),
 BLANK (),
 ( __PREV_QUARTER
 ))

 

 

Thanks in advance!

 

 

Sample:

https://drive.google.com/drive/folders/1TOYezhAuiy0ADTNcKVL1ayNw5XoLMo_I?usp=share_link

 

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Laocsulak ,

Please have a try.

Change the quanter column.

QUANTER = var _year=YEAR(Sheet1[created])
var _year1=YEAR(Sheet1[created])-1
var _q=QUARTER(Sheet1[created])
var _qa=QUARTER(Sheet1[created])-1
var _1re=
_year&"/"&"Q"&_qa
return
IF(_q=1,_year1&"/"&"Q"&4,_1re)

vpollymsft_0-1674092105922.pngvpollymsft_1-1674092120028.pngvpollymsft_2-1674092130135.png

and it is  affected by the slicer.

If it still does not help,Please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Laocsulak , 

Please have a try.

Create columns and measures.

QUANTER =
VAR _year =
    YEAR ( Sheet1[created] )
VAR _q =
    QUARTER ( Sheet1[created] )
RETURN
    _year & "/" & "Q" & _q
DAYS = DAY(Sheet1[created])

Measure:

Measure =
CALCULATE (
    SUM ( Sheet1[amount] ),
    FILTER (
        ALL ( Sheet1 ),
        Sheet1[DAYS] <= MAXX ( ALLSELECTED ( Calendario ), Calendario[Dia] )
            && Sheet1[QUANTER] = SELECTEDVALUE ( Calendario[Año/trimestre] )
    )
)

vpollymsft_0-1674009592375.pngvpollymsft_1-1674009606372.png

How to Get Your Question Answered Quickly 

 

If it still does not help,Please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

Thanks for the answer, although I have tried that and it shows the sales of the current quarter, I need to show the sales of the previous quarter, and also it's not affected by the slicer.

 

Laocsulak_0-1674047177682.png

 

Anonymous
Not applicable

Hi @Laocsulak ,

Please have a try.

Change the quanter column.

QUANTER = var _year=YEAR(Sheet1[created])
var _year1=YEAR(Sheet1[created])-1
var _q=QUARTER(Sheet1[created])
var _qa=QUARTER(Sheet1[created])-1
var _1re=
_year&"/"&"Q"&_qa
return
IF(_q=1,_year1&"/"&"Q"&4,_1re)

vpollymsft_0-1674092105922.pngvpollymsft_1-1674092120028.pngvpollymsft_2-1674092130135.png

and it is  affected by the slicer.

If it still does not help,Please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

 

amitchandak
Super User
Super User

@Laocsulak , Try if measure like this can help

trailing QTR = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,QUARTER))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I have tried that measure before, but when the quarter has not ended, it doesn't show the right amount for the previous quarter. In this example, it shows 10 instead of 24 in the last quarter.

 

Laocsulak_0-1673971634718.png

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.