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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
v-yangliu-msft
Community Support
Community Support

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.