Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all,
I am trying to find a way to manually set target goals for my KPI visual based on a filtered value (base currency). The goals for each currency are as follows:
I can get the goals to work for one given currency (say GBP), by using the code
ActDocsRedTarg = IF(HASONEVALUE(KPI2[ActiveDocsRed]), VALUES(KPI2[ActiveDocsRed]), CALCULATE(MINA(KPI2[ActiveDocsRed]), KPI2[CurrencyCode] = "GBP"))
and it appears as it should
But this isn't very useful when the currency code is say USD where the goals should be 1250 and 2500 as I have had to hardcode GBP into the DAX.
Is there a way I can write the last bit of code to say something like:
... KPI2[CurrencyCode] = (Value which has been filtered)
Thanks in advance!
Solved! Go to Solution.
@Anonymous
Try adding a FILTER in your formula.
ActDocsRedTarg = IF( HASONEVALUE(KPI2[ActiveDocsRed]), VALUES(KPI2[ActiveDocsRed]), CALCULATE( MINA(KPI2[ActiveDocsRed]), FILTER(KPI2, KPI2[CurrencyCode] = SELECTEDVALUE(GeneralLedgerStructure[BaseCurrency]) ) )
@Anonymous
hi, try with SELECTEDVALUE.
Regards
Victor
I have rearranged the code for ease. And GeneralLedgerStructure[BaseCurrency] is the field being filtered and only contains currency values from the previous post.
I tried with SELECTEDVALUE but it just returned the error:
"A function 'SELECTEDVALUE' has been used in a True/False expression that is used as a table filter expression. This is not allowed."
This is my code
ActDocsRedTarg = IF( HASONEVALUE(KPI2[ActiveDocsRed]), VALUES(KPI2[ActiveDocsRed]), CALCULATE( MINA(KPI2[ActiveDocsRed]), KPI2[CurrencyCode] = SELECTEDVALUE(GeneralLedgerStructure[BaseCurrency]) ) )
@Anonymous
Try adding a FILTER in your formula.
ActDocsRedTarg = IF( HASONEVALUE(KPI2[ActiveDocsRed]), VALUES(KPI2[ActiveDocsRed]), CALCULATE( MINA(KPI2[ActiveDocsRed]), FILTER(KPI2, KPI2[CurrencyCode] = SELECTEDVALUE(GeneralLedgerStructure[BaseCurrency]) ) )
It works!
Thank you!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
111 | |
92 | |
84 | |
66 |