Forum Discussion

mai_2020's avatar
mai_2020
Frequent Visitor
5 years ago
Solved

Complex measures while comparing sales figures with switch functions

Hi everyone,   I have a situation as follows: I want to create a possibility for my users to choose what numbers they can compare with what. We are talking company performance, so i have sales, sa...
  • MFelix's avatar
    5 years ago

    Hi mai_2020 ,

     

    You need to use the setup following the description of SQLBI but in this case you need to make some changes to the model.

     

    My setup is has follow:

     

    Now I have added the following measure:

    Sales Currency =
    VAR DatesExchange =
        ADDCOLUMNS (
            SUMMARIZE (
                Sales,
                'Date'[Year-Month],
                'Currency'[Currency],
                "@TotalSales", SUM ( Sales[Value] )
            ),
            "@ExchangeAverageRate", CALCULATE ( SELECTEDVALUE ( Exchange[Exchange] ) )
        )
    VAR Result =
        SUMX ( DatesExchange, [@TotalSales] * [@ExchangeAverageRate] )
    RETURN
        Result

     

    Result below and in attach PBIX file. Be aware that you may need to change the grouping on the summarize to fit your needs.