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.
Hi
I am trying to group customers by 4 segements. Those who hold both Index Funds & Stocks, Index Fund Only, Stocks Only, and those who hold nothing.
I created a segments measure based on some conditions which gives me this output in table.
Total Value = SUM ( Investments[Value] )
Index Fund Value = CALCULATE ([Total Value], FILTER(Asset, Asset[Asset Type] = "Index Funds" )
Stocks Value = CALCULATE ([Total Value], FILTER(Asset, Asset[Asset Type] = "Stocks" )
Segments =
SWITCH(
TRUE(),
[Index Fund Value]>0 && [Stocks Value]>0, "Index Funds & Stock",
[Index Fund Value]>0 && [Stocks Value]<=0, "Index Funds Only",
[Index Fund Value]<=0 && [Stocks Value]>0, "Stocks Only",
[Index Fund Value]<=0 && [Stocks Value]<=0, "Nothing",
BLANK())
The output snapshot is this:
I now need to be able to count how many customers are in each segment and represent it in a bar chart that looks like this:
So each bar would show the count of customers in each segment.
I tried to use a disconnected table but not sure how it works win this scenario. I have tried multiple techniques but cant seem to get the right measure.
This is the PBIX im working with.
https://drive.google.com/file/d/1r_rNN995HPC6CWIJV7zH_bDZ7QylFEFo/view?usp=sharing
Solved! Go to Solution.
This measure seems to work:
Filter measure =
IF (
ISFILTERED ( Segments[Segment] ),
COUNTROWS (
FILTER ( Customer, [Segments] IN { VALUES ( Segments[Segment] ) } )
),
1
)
Select the table visual, add the measure to the filters for the visual in the filter pane and set the value to "is 1"
Edit: the filtering should work if you select more than one bar using ctrl
Proud to be a Super User!
Paul on Linkedin.
@av9 In general, to use a measure in that way, you need to use the Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick...
I gave that a try and but couldn't quite figure it out for my sceanrio. I tried another one of your techniques I came across and it gave me a bar chart I am after, but was wandering if you knew how to ensure I can still crossfilter in the visuals in teh report. I.e you click on the bar and it filters the table?
Count of Segment =
VAR Segment =SELECTEDVALUE(Segments[Segment],"All")
RETURN
SWITCH(true(),
Segment="Index Funds & Stocks", COUNTX(FILTER(Customer,[Segments]="Index Funds & Stocks"),Customer[CustomerID]),
Segment="Index funds Only",COUNTX(FILTER(Customer,[Segments]="Index funds Only"),Customer[CustomerID]),
Segment="Stocks Only", COUNTX(FILTER(Customer,[Segments]="Stocks Only"),Customer[CustomerID]),
Segment="Nothing", COUNTX(FILTER(Customer,[Segments]="Nothing"),Customer[CustomerID])
)
This measure seems to work:
Filter measure =
IF (
ISFILTERED ( Segments[Segment] ),
COUNTROWS (
FILTER ( Customer, [Segments] IN { VALUES ( Segments[Segment] ) } )
),
1
)
Select the table visual, add the measure to the filters for the visual in the filter pane and set the value to "is 1"
Edit: the filtering should work if you select more than one bar using ctrl
Proud to be a Super User!
Paul on Linkedin.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
111 | |
92 | |
84 | |
66 |