7

I want to create switch button that will be changing date (By Accounting date or by Effective date) by which report is viewed.

Currently, I have active relationship by Effective date and inactive relationship by Accounting date.

enter image description here

Using USERELATIONSHIP function I am able to bring data by both dates:

Total Premium by AccDate =
    CALCULATE( Sum(Premiums[Premium]),
        USERELATIONSHIP(Premiums[AccountingDate], Dates[Date]))

enter image description here

So my question, how can I place a button (switch) so end user would simply click on that button (whether effective date or accounting date) and all visuals would display data according to the switch?

Do I need to use bookmarks for that? Or there are some other tricks?

Alexis Olson
  • 38,724
  • 7
  • 42
  • 64
Serdia
  • 4,242
  • 22
  • 86
  • 159

1 Answers1

9

Let's suppose you've created a new Slicer table to use as a slicer:

Type
----
Accounting Date
Effective Date

Using your two different premium measures,

Total Premium by AccDate =
    CALCULATE( Sum(Premiums[Premium]),
        USERELATIONSHIP(Premiums[AccountingDate], Dates[Date]))

Total Premium by EffDate =
    CALCULATE( Sum(Premiums[Premium]),
        USERELATIONSHIP(Premiums[EffectiveDate], Dates[Date]))

you can create a new measure that switches between these two based on your slicer selection:

Total Premium = 
    SWITCH(SELECTEDVALUE(Slicer[Type]),
           "Accounting Date", [Total Premium by AccDate],
           "Effective Date", [Total Premium by EffDate])
Alexis Olson
  • 38,724
  • 7
  • 42
  • 64