Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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.

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]))

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?

Please post some sample data and I will show you an alternative approach, very simple and without using function USERELATIONSHIP. – Przemyslaw Remin Dec 17, 2019 at 14:11
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])
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.