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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

using less or equal in filter

Hi,

 

In a source table I have a field that contains a number between 1 and 50.

In a page I want to show its records using a table vizualisation.

I want to use a slicer with the values 5, 10, 15, 20, 25, ..., 50

If I select e.g. the value 20 in the slicer, then in the table I get all records with the number 1 to 20

If I select e.g. the value 35 in the slicer, then in the table I get all records with the number 1 to 35

etc.

 

I tried to add a new column =(TRUNC((number-1)/5)+1)*5, but selecting 20 in the slicer, then in the table I get only the records with number 16 to 20, selecting 35 in the slicer, then in the table I get only the records with number 31 to 35

 

I tried to use a new table where I typed in the values 5, 10, 15, 20, ... , 50 and use this for the slicer. And I added a filter where number should be less or equal the selected value in the slicer. The filter doesn't work: all records are shown.

 

How can I solve this problem?

 

Thanks

 

R.W.

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

So to replicate your problem I have setup a table in power query that contains two columns, one with an Id column from 0 to 24 and another column with a random integer between 1 and 50 called values. Then I have created another table that just contains numbers between 5 and 50 in increments of 5. There are no relationships between these two tables.

 

Then to get the result you require I have the following measure

 

 

Values Filtered =
    IF (
        HASONEVALUE ( 'Filter Table'[Filter] ) && HASONEVALUE ( 'Table'[Id] ),
        CALCULATE (
            VALUES ( 'Table'[Value] ),
            FILTER ( ( 'Table' ), 'Table'[Value] <= VALUES ( 'Filter Table'[Filter] ) )
        ),
        BLANK ()
    )

What it does is check if in the current context if there is only one value of Id, aka only one row of the Table is in the current context, and that there is only one value selected from the filter table. If either of these are false it will return blank, if you want some kind of aggregation it can be added.

 

 

If the conditions are met then it will display the values that are less than or equal to the selected value of the fitler table.

image.png

 

I hope this helps

 

View solution in original post

@Anonymous,

Yes if you use @Anonymous's DAX. You can add an index column in Query Editor to represent ID.  


1.PNG

Or you can change the DAX to the following ,for more details, please check attached PBIX file. It doesn't require Id column using this DAX.

Measure = 
    IF (
        HASONEVALUE ( Parameter[Parameter] ) && HASONEVALUE ( 'Table1'[Value] ),
        CALCULATE (
            VALUES ( Table1[Value] ),
            FILTER ( ( 'Table1' ), Table1[Value] <= VALUES ( Parameter[Parameter] ) )
        ),
        BLANK ()
    )


1.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
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

3 REPLIES 3
Anonymous
Not applicable

So to replicate your problem I have setup a table in power query that contains two columns, one with an Id column from 0 to 24 and another column with a random integer between 1 and 50 called values. Then I have created another table that just contains numbers between 5 and 50 in increments of 5. There are no relationships between these two tables.

 

Then to get the result you require I have the following measure

 

 

Values Filtered =
    IF (
        HASONEVALUE ( 'Filter Table'[Filter] ) && HASONEVALUE ( 'Table'[Id] ),
        CALCULATE (
            VALUES ( 'Table'[Value] ),
            FILTER ( ( 'Table' ), 'Table'[Value] <= VALUES ( 'Filter Table'[Filter] ) )
        ),
        BLANK ()
    )

What it does is check if in the current context if there is only one value of Id, aka only one row of the Table is in the current context, and that there is only one value selected from the filter table. If either of these are false it will return blank, if you want some kind of aggregation it can be added.

 

 

If the conditions are met then it will display the values that are less than or equal to the selected value of the fitler table.

image.png

 

I hope this helps

 

Anonymous
Not applicable

Thomas,

 

Thanks.

 

Is the ID necessary in this construction?

In my table I don't have an ID.

 

R.W.

@Anonymous,

Yes if you use @Anonymous's DAX. You can add an index column in Query Editor to represent ID.  


1.PNG

Or you can change the DAX to the following ,for more details, please check attached PBIX file. It doesn't require Id column using this DAX.

Measure = 
    IF (
        HASONEVALUE ( Parameter[Parameter] ) && HASONEVALUE ( 'Table1'[Value] ),
        CALCULATE (
            VALUES ( Table1[Value] ),
            FILTER ( ( 'Table1' ), Table1[Value] <= VALUES ( Parameter[Parameter] ) )
        ),
        BLANK ()
    )


1.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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