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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
konradjonsson
Helper II
Helper II

Dynamic parameters in a variable formula

Hi.

I want to make two parameters of my formula dynamic, i.e. replace the fixed values with values that the person running the report is selecting. The specific values are WKCurrencyType (=2) and WKRreportCurrency (=133).

-these two I would like to be able to select while running the report.

 

What solutions are there for this?

 

CURRENT FORMULA

ExchangeRate =

VAR _date = 'Sales'[WKInvoiceDate]

VAR _currency = 'Sales'[WKCurrency]

RETURN

CALCULATE( MAX('Exchange Rates'[ExchangeRates] ), year('Exchange Rates'[WKDate]) = year(_date), 'Exchange Rates'[WKSourceCurrency] = _currency, 'Exchange Rates'[WKCurrencyType]=2,'Exchange Rates'[WKReportCurrency]=133 )

1 ACCEPTED SOLUTION

Hi, @konradjonsson 
If [WKInvoiceDate],[WKCurrency],[parameter1 value],[parameter2 value] are measure columns, try to encapsulate all conditions with filter function.


Measure:

ExchangeRate =
VAR _date = 'Sales'[WKInvoiceDate]
VAR _currency = 'Sales'[WKCurrency]
RETURN
    CALCULATE (
        MAX ( 'Exchange Rates'[ExchangeRates] ),
        FILTER (
            'Exchange Rates',
             YEAR ( 'Exchange Rates'[WKDate] ) = YEAR ( _date )
                && 'Exchange Rates'[WKSourceCurrency] = _currency
                && 'Exchange Rates'[WKCurrencyType] = [parameter1 value]
                && 'Exchange Rates'[WKReportCurrency] = [parameter2 value]
        )
    )

 

Best Regards,
Community Support Team _ Eason

View solution in original post

5 REPLIES 5
konradjonsson
Helper II
Helper II

I created a What if-parameter, to replace the fixed currency settings (133). I got an error message saying; "A function 'PLACEHOLDER' has been used in a True/False expression that is used as a table filter expression. This is not allowed."

 

I do not how to address this.

Hi, @konradjonsson 
If [WKInvoiceDate],[WKCurrency],[parameter1 value],[parameter2 value] are measure columns, try to encapsulate all conditions with filter function.


Measure:

ExchangeRate =
VAR _date = 'Sales'[WKInvoiceDate]
VAR _currency = 'Sales'[WKCurrency]
RETURN
    CALCULATE (
        MAX ( 'Exchange Rates'[ExchangeRates] ),
        FILTER (
            'Exchange Rates',
             YEAR ( 'Exchange Rates'[WKDate] ) = YEAR ( _date )
                && 'Exchange Rates'[WKSourceCurrency] = _currency
                && 'Exchange Rates'[WKCurrencyType] = [parameter1 value]
                && 'Exchange Rates'[WKReportCurrency] = [parameter2 value]
        )
    )

 

Best Regards,
Community Support Team _ Eason

konradjonsson
Helper II
Helper II

Thanks! Will try this.

Anonymous
Not applicable

Hi, you can use this “New parameter”,in Modeling

amitchandak
Super User
Super User

@konradjonsson, You can use what if the parameter of some other slicer value 

CURRENT FORMULA

ExchangeRate =

VAR _date = 'Sales'[WKInvoiceDate]

VAR _currency = 'Sales'[WKCurrency]

RETURN

CALCULATE( MAX('Exchange Rates'[ExchangeRates] ), year('Exchange Rates'[WKDate]) = year(_date), 'Exchange Rates'[WKSourceCurrency] = _currency, 'Exchange Rates'[WKCurrencyType]=selectedvalues(whatif1[Value]) ,'Exchange Rates'[WKReportCurrency]=selectedvalues(whatif2[Value]) )

 

 

https://docs.microsoft.com/en-us/power-bi/desktop-what-if

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.