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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Rob92
Frequent Visitor

Conditional Measure using slicer selection

I am trying to put together a stacked column chart, using the example table below, I want to show total transactions per month. The one color of the stacked column will show transactions by clients who joined before the start of the selected date range (marked those in bold below), and the other color of the bar will be transactions by clients who joined after the start of the selected date range (marked those in italics below).  The user needs the ability to chose the date range with a slice.  In this example let's say the user has chosen 1/1/24 - 3/31/24.  So the Jan column would show a total of 18 transactions (16 from old clients, 2 from new), Feb would show 24 transactions (14 from old clients, 10 from new), and Mar would show 33 transactions (13 from old clients, 20 from new).

 

If the user changes the date range, the clients that are considered old or new will change.  Here if they changed the range to 2/1/24 - 3/31/24, then client C would change from the new catagory to old.

 

Since the user needs control of the date range, I can't code these catagories into the datasource. I know I can't reference a single slicer value in a calculated column formula.  So I'm trying to figure out if I can achieve this with a measure, using SWITCH and SELECTEDVALUE to check if a Client_joined date is before or after the start of the date range the user sets, and catagorize the transactions in the visual dynamically that way. Any thoughts on this?  Or any other ways I could achieve this result?  Thanks in advance!

 

ClientClient_joinedTransactionsTransaction_month
A5/5/20239Jan-24
B10/10/20237Jan-24
C1/20/20242Jan-24
A5/5/20238Feb-24
B10/10/20236Feb-24
C1/20/20247Feb-24
D2/15/20243Feb-24
A5/5/20238Mar-24
B10/10/20235Mar-24
C1/20/20246Mar-24
D2/15/20248Mar-24
E3/5/20246Mar-24
2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Rob92 ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a sperated date dimension table(DO NOT create any relationship with your fact table) just as suggested by Ibendlin

vyiruanmsft_1-1723699553307.png

2. Create two measures as below

Old clients count = 
VAR _mindate =
    MIN ( 'Date'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Table'[Transactions] ),
        FILTER ( 'Table', 'Table'[Client_joined] <= _mindate )
    )
New clients count = 
VAR _mindate =
    MIN ( 'Date'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Table'[Transactions] ),
        FILTER ( 'Table', 'Table'[Client_joined] > _mindate )
    )

3. Create a table visual as shown in the below screenshot

vyiruanmsft_0-1723699463902.png

Best Regards

View solution in original post

Rob92
Frequent Visitor

Awesome, thanks guys!  I have implemented the solution on my real data and it works a treat.  The only issue was that as well as the slicer controlling which users are new or old, I also need it to filter the visual.  In order to do this I have joined the date dimension table to the fact table.  This causes the date hierachy to break but that's not a problem - to resolve that, I added separate month and year columns in power query, and used those on the X axis instead.  Problem solved!

 

Rob92_0-1723720609172.png

 

View solution in original post

3 REPLIES 3
Rob92
Frequent Visitor

Awesome, thanks guys!  I have implemented the solution on my real data and it works a treat.  The only issue was that as well as the slicer controlling which users are new or old, I also need it to filter the visual.  In order to do this I have joined the date dimension table to the fact table.  This causes the date hierachy to break but that's not a problem - to resolve that, I added separate month and year columns in power query, and used those on the X axis instead.  Problem solved!

 

Rob92_0-1723720609172.png

 

Anonymous
Not applicable

Hi @Rob92 ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a sperated date dimension table(DO NOT create any relationship with your fact table) just as suggested by Ibendlin

vyiruanmsft_1-1723699553307.png

2. Create two measures as below

Old clients count = 
VAR _mindate =
    MIN ( 'Date'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Table'[Transactions] ),
        FILTER ( 'Table', 'Table'[Client_joined] <= _mindate )
    )
New clients count = 
VAR _mindate =
    MIN ( 'Date'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Table'[Transactions] ),
        FILTER ( 'Table', 'Table'[Client_joined] > _mindate )
    )

3. Create a table visual as shown in the below screenshot

vyiruanmsft_0-1723699463902.png

Best Regards

lbendlin
Super User
Super User

You need to use a disconnected table to feed your date range slicer, and then use measures to filter your visual.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.