Forum Discussion

Rob92's avatar
Rob92
Frequent Visitor
2 years ago
Solved

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 w...
  • Anonymous's avatar
    Anonymous
    2 years ago

    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

    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

    Best Regards

  • Rob92's avatar
    2 years ago

    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!