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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Velvetine27
Helper I
Helper I

Multiple selection filters not working

Hi all,

 

I wrote a DAX to display data up till the selected month like this : 

 

%CFR=
VAR selectedYear =
    SELECTEDVALUE ( 'DATE'[Date].[Year] )
VAR selectedMon =
    SELECTEDVALUE ( 'DATE'[Date].[MonthNo] )
VAR start_ =
    DATE ( selectedYear, 1, 1 )
VAR end_ =
    DATE ( selectedYear, selectedMon + 1, 1 ) - 1

RETURN
CALCULATE(([DO] / [SO]),FILTER ( 'TABLE', 'TABLE'[date] >= start_ && 'TABLE'[date] <= end_ ))
 
 
 
Now the issue is that in my visuals if the user selects more than one month, this doesn't work. Do you guys have any suggestions how can I keep the functionality of current DAX while allowing users to select multiple months and it will show data up till the last selected month. So if users choose all months, it should display the entire year of data. Any suggestions appreciated. 
 
Thanks !
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Velvetine27 

 try like:

%CFR=
VAR selectedYear =
    YEAR(MAX('DATE'[Date]))
VAR selectedMon =
    MONTH(MAX('DATE'[Date]))
VAR start_ =
    DATE ( selectedYear, 1, 1 )
VAR end_ =
    DATE ( selectedYear, selectedMon + 1, 1 ) - 1
RETURN
CALCULATE(([DO] / [SO]),FILTER ( 'TABLE', 'TABLE'[date] >= start_ && 'TABLE'[date] <= end_ ))

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @Velvetine27 ,

I created some data:

Table:

vyangliumsft_0-1673336848494.png

Date:

vyangliumsft_1-1673336848495.png

 

Here are the steps you can follow:

1. Create measure.

Flag =
var _selectyear=SELECTEDVALUE('Date'[Year])
var _selectmonth=MAXX(ALLSELECTED('Date'),[Month])
var _start=DATE(_selectyear,1,1)
var _end=EOMONTH(DATE(_selectyear,_selectmonth,1),0)
return
IF(
    MAX('Table'[date]) >=_start && MAX('Table'[date])<=_end,1,0)
Measure =
SUMX(ALLSELECTED('Table'),[DO/SO])

2. Result:

vyangliumsft_2-1673336848499.png

Best Regards,

Liu Yang

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

FreemanZ
Super User
Super User

hi @Velvetine27 

 try like:

%CFR=
VAR selectedYear =
    YEAR(MAX('DATE'[Date]))
VAR selectedMon =
    MONTH(MAX('DATE'[Date]))
VAR start_ =
    DATE ( selectedYear, 1, 1 )
VAR end_ =
    DATE ( selectedYear, selectedMon + 1, 1 ) - 1
RETURN
CALCULATE(([DO] / [SO]),FILTER ( 'TABLE', 'TABLE'[date] >= start_ && 'TABLE'[date] <= end_ ))

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.