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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Value between two columns

I have a table that contains FROM and THROUGH serial number (not date) range values for a product line.

I would like to build a slicer that will find all rows where the input value with BETWEEN the FROM and THROUGH values. 

The table below shows what I am looking for. 

Ideally I would have a single range slider where I could specify a start and end range and any rows where the FROM and THROUGH overlapped at all would be included. 

 

The real world use cases are:

Show me all the parts that were contained in unit number 5. 

Show me all the parts that were contained in units 20 - 50. 

 

CSimpson_0-1621026705464.png

 

1 ACCEPTED SOLUTION

Hi @Anonymous 

EDIT: Forgot the attachment - just attached it!

Thanks for testing this out!

 

After looking at your overall requirements, I think this is a good candidate for a Calculation Group, with a Calculation Item that applies the range filter to the parts .

When the Calculation Item is applied as a filter, the "range" filter will be applied to any measures used in the visuals.

 

I have attached an updated PBIX, with a PartChild table added (hopefully similar to yours).

 

1. The first thing I did was create a Calculation Group called Parts Filter, with a single column Parts Filter, with a Calculation Item Parts in Range. This Calculation Item is defined as

 

VAR MinValue =
    MIN ( Range[Value] )
VAR MaxValue =
    MAX ( Range[Value] )
RETURN
    CALCULATE (
        SELECTEDMEASURE (),
        'Product'[FROM] <= MaxValue,
        'Product'[THROUGH] >= MinValue
    )

 

If you haven't created Calculation Groups before, you'll need Tabular Editor. See here for example.

 

2. Next I applied a Page filter, selecting Parts Filter = "Parts in Range".

 

3. Then I ensured that all visuals use explicit measures, namely:

 

Part Count = 
COUNTROWS ( 'Product' )

Child Count = 
COUNTROWS ( PartChild )

 

 

4. The above measures work fine on cards/pie charts. However table visuals with no measures displayed need a have a measure injected somehow. I chose to apply a visual level filter of Part Count is not blank to the table visuals, which is modified by the Calculation Gruop.

 

What do you think of this method? I think it simplifies applying the range filter and saves writing multiple measures with the same filter.

OwenAuger_0-1621374038102.png

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

8 REPLIES 8
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
OwenAuger
Super User
Super User

Hi @Anonymous 

I would recommend a measure using something similar to the Events in progress pattern.

Specifically the # Open Orders ALL measure in the above article.

 

If you have created a disconnected table containing values to use on a range slicer, with column called say Range[Value], you can then create a measure like this:

# Products in Range = 
VAR MinValue = MIN ( Range[Value] )
VAR MaxValue = MAX ( Range[Value] )
RETURN
    CALCULATE ( 
        COUNTROWS ( 'Product' ),
        'Product'[FROM] <= MaxValue,
        'Product'[THROUGH] >= MinValue
    )

 

Then if you have a visual that includes the PART column, you can apply a visual-level filter with # Products in Range is not blank or # Products in Range >= 1.

 

See attached PBIX for an example.

 

OwenAuger_0-1621039016533.png

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn
Anonymous
Not applicable

@OwenAuger Thanks for the clear reply, I had tried something like that before but it was not filtering linked tables. I added another table (shown below) to your example and it does work so I must have missed something. This is very close to Nirvana for me, but none of the cards or graphs work with that measure as a filter so you can't show any useful summary data. 

 

I would send back a the pbix but the system won't let me attach. So, here is the scenario:

 

Added table shown below to the data model and linked to the original Part table. 

Added same table to the report and put the measure as a filter. 

Added pie chart with Part as the legend and count of Child as the value. 

 

Adjust the slider and see the tables in the report adjust but not the graphs. 

Any ideas? 

 

Part    Child

AA1
AA2
AA3
BB1
CC1
CC2
DD1
DD2
EE1
FF1
GG1

 

CSimpson_0-1621368396451.png

 

Hi @Anonymous 

EDIT: Forgot the attachment - just attached it!

Thanks for testing this out!

 

After looking at your overall requirements, I think this is a good candidate for a Calculation Group, with a Calculation Item that applies the range filter to the parts .

When the Calculation Item is applied as a filter, the "range" filter will be applied to any measures used in the visuals.

 

I have attached an updated PBIX, with a PartChild table added (hopefully similar to yours).

 

1. The first thing I did was create a Calculation Group called Parts Filter, with a single column Parts Filter, with a Calculation Item Parts in Range. This Calculation Item is defined as

 

VAR MinValue =
    MIN ( Range[Value] )
VAR MaxValue =
    MAX ( Range[Value] )
RETURN
    CALCULATE (
        SELECTEDMEASURE (),
        'Product'[FROM] <= MaxValue,
        'Product'[THROUGH] >= MinValue
    )

 

If you haven't created Calculation Groups before, you'll need Tabular Editor. See here for example.

 

2. Next I applied a Page filter, selecting Parts Filter = "Parts in Range".

 

3. Then I ensured that all visuals use explicit measures, namely:

 

Part Count = 
COUNTROWS ( 'Product' )

Child Count = 
COUNTROWS ( PartChild )

 

 

4. The above measures work fine on cards/pie charts. However table visuals with no measures displayed need a have a measure injected somehow. I chose to apply a visual level filter of Part Count is not blank to the table visuals, which is modified by the Calculation Gruop.

 

What do you think of this method? I think it simplifies applying the range filter and saves writing multiple measures with the same filter.

OwenAuger_0-1621374038102.png

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn
dkaushik
Resolver II
Resolver II

You don't need to I guess. You can simply use the other table's single column and the you can choose your own from and to values directly from the slicer. 

Anonymous
Not applicable

Sorry, still being dense here. I don't understand how to "use the other table's single column"
Assume this simplistic table structure: 

CSimpson_0-1621037954750.png

 

 


Putting slicers simply on the FROM and THROUGH values does not yield what I need. 
Do I build a relationship between the two tables? 

I have tried using the <= and >= options on separate slicers and configured them either way and it does not return all the rows that overlap the specified range. 

 

A single slicer on either column won't do it either. If I put in 10 as in input value I would want to see rows that have 10 anywhere between the FROM and THROUGH. 

 

Thanks for your responses. 

dkaushik
Resolver II
Resolver II

Hi @Anonymous ,

 

You can achieve this by using a single column where you have values from 1 to max range. Then use that column in a slicer and use the option "Between" from the downward arrow in top right, as shown below:

dkaushik_0-1621027393339.png

 

Thanks,

Dheeraj

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

Anonymous
Not applicable

Thanks, but I don't really understand how to put the pieces together. I do have another table that has a single column I can leverage but I can't connect this table to it with both the FROM and THROUGH values since that would be multiple relationships.  

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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