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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
jimi123
Regular Visitor

Previous month selected with interval

Hi Could someone help me with the below

 

I have a slice filter where I have my Month-Year field from my calendar table

jimi123_0-1686811805924.png

 

 

I need to have a measure in which I should capture a column field related to the previous month.

For example, in the case above it should return Apr 23 - Total Session Value (here the it's correct)

jimi123_1-1686811972436.png

 

THE PROBLEM: is that if I unselected Apr 23 from the slicer filter I expect that the value returned should be from Mar 23, but it keeps returning the value from Apr 23....I need that the returned value "Total Sessions last Month" should be 70881

jimi123_3-1686812136914.png

 

jimi123_4-1686812219922.png

jimi123_5-1686812234621.png

 

 

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jimi123 ,

 

I created a sample file for your reference.

Sample data:

vstephenmsft_0-1687417666607.png

There's no relationship between the main table and the calendar table.

vstephenmsft_2-1687417745891.png

 

Create a measure for the visual-level filters.

Measure = 
var _select=SELECTCOLUMNS('Calendar',"1",'Calendar'[MonthYear])
var _date1=
MAXX(
    FILTER(ALL('Calendar'),'Calendar'[MonthYear] in _select),[Date])
var _datecolumn=
SELECTCOLUMNS(
    FILTER(ALL('Calendar'),'Calendar'[MonthYear] in _select&&YEAR(MAX('Table'[Date]))=YEAR(_date1)&&MONTH(MAX('Table'[Date]))<>MONTH(_date1)),"1",[Date])
return
IF(ISFILTERED('Calendar'[MonthYear]),IF(
    MAX('Table'[Date]) in _datecolumn,1,0),1)

Put the measure into the Filters and set up show items when the value is 1.

vstephenmsft_3-1687417835759.png

Here's the result.

vstephenmsft_4-1687417905724.png

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @jimi123 ,

 

I created a sample file for your reference.

Sample data:

vstephenmsft_0-1687417666607.png

There's no relationship between the main table and the calendar table.

vstephenmsft_2-1687417745891.png

 

Create a measure for the visual-level filters.

Measure = 
var _select=SELECTCOLUMNS('Calendar',"1",'Calendar'[MonthYear])
var _date1=
MAXX(
    FILTER(ALL('Calendar'),'Calendar'[MonthYear] in _select),[Date])
var _datecolumn=
SELECTCOLUMNS(
    FILTER(ALL('Calendar'),'Calendar'[MonthYear] in _select&&YEAR(MAX('Table'[Date]))=YEAR(_date1)&&MONTH(MAX('Table'[Date]))<>MONTH(_date1)),"1",[Date])
return
IF(ISFILTERED('Calendar'[MonthYear]),IF(
    MAX('Table'[Date]) in _datecolumn,1,0),1)

Put the measure into the Filters and set up show items when the value is 1.

vstephenmsft_3-1687417835759.png

Here's the result.

vstephenmsft_4-1687417905724.png

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

some_bih
Super User
Super User

Hi @jimi123 I understand you just need data for previous month? If yes your measure should be

CALCULATE(SUM(<your column name for summing>), PREVIOUSMONTH('Calendar'[Date]))

https://learn.microsoft.com/en-us/dax/previousmonth-function-dax 

I hope this help





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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