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

Partial filtering with a integer-based slicer visual

Hello,

 

I have the following simplified data:

State AState B
400600
450 
  
300450

 

I want to count the amount of rows in each state which are satisfied based on user input (a slicer). The user input is a threshold, above which all rows are not accepted. Let's say i set the slicer to 500.

 

In the first row, the values are 400 and 600 for state A and B, respectively. This means that the row is in state A, but not state B. In the fourth row, the values are 300 and 450. This means that the row is in state B.

 

My complete expected outcome would the following:

StateAmount
A2
B1
In neither state1

 

Let's say i slice based on the integer in the "State B"-column. I set the slicer to 500, but this filters out the entire row, even though state A is still satisfied.

 

I have tried many different methods but have not been able to figure out a solution. 

1 ACCEPTED SOLUTION

Hi @Anonymous 

Thanks for your reply.

 

The previous solution is based on this 

vxiaotang_1-1637571122247.png

Based on the new expected result, you can try this measure

State(dynamic) = 
    var _slicer=SELECTEDVALUE(Slicer[Parameter])
    var _stateA=SELECTEDVALUE('Table'[State A])
    var _stateB=SELECTEDVALUE('Table'[State B])

return 
    SWITCH(TRUE(),    
    ISBLANK(_stateA)&&ISBLANK(_stateB) || _slicer<_stateA,"In neither state",
    (_slicer>=_stateA && _slicer<_stateB ) || (_slicer>=_stateA&&ISBLANK(_stateB)),"A",
    _slicer>=_stateB,"B"
    )

result

vxiaotang_2-1637571174940.png

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

6 REPLIES 6
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

 

Is column [state A] smaller than [state B]? If so, you can try this measure,

Measure = 
    var _slicer=SELECTEDVALUE(Slicer[Parameter])
    var _a=CALCULATE(COUNT('Table'[State A]),FILTER('Table',('Table'[State A]<=_slicer&&'Table'[State B]>_slicer) || ('Table'[State A]<=_slicer&&ISBLANK('Table'[State B]))))
    var _b=CALCULATE(COUNT('Table'[State B]),FILTER('Table','Table'[State B]<=_slicer))
    var _n=CALCULATE(COUNTROWS('Table'),FILTER('Table',(ISBLANK('Table'[State A])&& ISBLANK('Table'[State B])) || 'Table'[State A]>_slicer))
return 
    SWITCH(TRUE(),
    MAX(Outcome[State])="A",_a,
    MAX(Outcome[State])="B",_b,
    _n)

vxiaotang_0-1636703883271.png

 

if you need more help, please @ me .

 

Best Regards,

Community Support Team _Tang

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

Anonymous
Not applicable

Hello again,

Yes, State A will always be equal to or smaller than State B.

 

Your suggestion is almost right. I however still want to be able to visualize the data contained in all the other columns and not just a summation of the number of rows fulfilling the if statement.

 

I have looked into the DATATABLE function, but it does not support dynamically editing the values of a column, each time a new slicer value is selected by the user.

 

The following table is my wanted result with slicer = 700:

IDState (dynamic)Property 1 (static)Property 2 (static)
A1Bxyz1xyz1
A2

A

xyz2xyz2
A3In neitherxyz3xyz3
B1Bxyz4xyz4

 

The following table is my wanted result with slicer = 350:

IDState (dynamic)Property 1 (static)Property 2 (static)
A1In neither statexyz1xyz1
A2In neither statexyz2xyz2
A3In neither statexyz3xyz3
B1Axyz4xyz4

 

Is this result achievable? 

Edit: It would also be acceptable to generate three lists containing the ID's in a given state. So e.g. {State A: ["A2"], State B: ["A1", "B1"], In neither state: ["A3"]}.

Hi @Anonymous 

Thanks for your reply.

 

The previous solution is based on this 

vxiaotang_1-1637571122247.png

Based on the new expected result, you can try this measure

State(dynamic) = 
    var _slicer=SELECTEDVALUE(Slicer[Parameter])
    var _stateA=SELECTEDVALUE('Table'[State A])
    var _stateB=SELECTEDVALUE('Table'[State B])

return 
    SWITCH(TRUE(),    
    ISBLANK(_stateA)&&ISBLANK(_stateB) || _slicer<_stateA,"In neither state",
    (_slicer>=_stateA && _slicer<_stateB ) || (_slicer>=_stateA&&ISBLANK(_stateB)),"A",
    _slicer>=_stateB,"B"
    )

result

vxiaotang_2-1637571174940.png

 

Best Regards,

Community Support Team _Tang

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

Anonymous
Not applicable

This is exactly what I needed, thanks for the support!

AlexisOlson
Super User
Super User

This will be easier to solve if you unpivot your data table.

State Amount
A 400
B 600
A 450
A 300
B 450

 

Is that possible in your case?

Anonymous
Not applicable

Thanks for the suggestion!

 

Unfortunately, it is not possible. Each row has a unique ID - the following table more accurately depicts the situation.

IDState AState B
A1400600
A2450 
A3  
B1300450

 

Furthermore, the unique ID and all the other columns in my actual data needs to be preserved.

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.