Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
I wanted to add conditional prefix ($ or €) in a column chart displaying sales in usd/euro according to the filter selection of currency. Measure has been created to display sales according to usd/euro but want to add conditional prefix as well.
P.S- I can't edit the measure, so there anything in visual formatting with which I can achieve this?
Solved! Go to Solution.
@Anonymous
VAR curr_code =
SELECTEDVALUE ( sCurrency[to_currency] )
RETURN
SWITCH (
curr_code,
"USD", FORMAT ( SUM ( Sales[innovation_sales_usd] ), "$ #,0.00" ),
"EUR", FORMAT ( SUM ( Sales[innovation_sales_eur] ), "€ #,0.00" ),
"Local", FORMAT ( SUM ( Sales[innovation_sales] ), "? #,0.00" )
)
this will only work on visuals that can show text like matrix, table, etc.
You won't be able to use this for charts. This is becasue the result is text, you are loosing the knowledge of the value. If you wan't to keep also the value and change the format string dynamically you must use calculation groups.
@Anonymous
VAR curr_code =
SELECTEDVALUE ( sCurrency[to_currency] )
RETURN
SWITCH (
curr_code,
"USD", FORMAT ( SUM ( Sales[innovation_sales_usd] ), "$ #,0.00" ),
"EUR", FORMAT ( SUM ( Sales[innovation_sales_eur] ), "€ #,0.00" ),
"Local", FORMAT ( SUM ( Sales[innovation_sales] ), "? #,0.00" )
)
this will only work on visuals that can show text like matrix, table, etc.
You won't be able to use this for charts. This is becasue the result is text, you are loosing the knowledge of the value. If you wan't to keep also the value and change the format string dynamically you must use calculation groups.
I want to use this measure as a value for stacked column chart. So what shall I do?
Only with Calculation Groups. This is a topic of it's own.
check out this:
https://www.youtube.com/watch?v=-REAQDqdz0A
and more general examples for CG's:
https://apexinsights.net/blog/10-uses-for-calculation-groups
and from SQLBI specifically:
https://www.sqlbi.com/?s=calculation%20groups&type=video
what is not available there means it's from a course.
Thank you so much. Can you suggest me any source from where I can learn complete Dax for Power BI?
This is easy.
Only at www.sqlbi.com. The gods of DAX.
They have a lot of free material but I suggest taking the complete training that does cost money or read their book.
You will find in their website so many things 🙂
"Enjoy DAX! ":)
@Anonymous
If you can't edit the measure try bookmarks. 1 for each version of currency value and visual formatting
You will need to use the buttons between the different views.
The slicer can't do it by it's on, maybe if youdo some ugly stuff in the model but if can't edit the measure I guess you don't have access to the model.
Anyway, your best option is to do this with calculation groups, but that is also requiring editing the model itself
VAR curr_code = SELECTEDVALUE(sCurrency[to_currency])
RETURN
SWITCH (curr_code,
"USD", sum(Sales[innovation_sales_usd]),
"EUR", sum(Sales[innovation_sales_eur]),
"Local", sum(Sales[innovation_sales])
)
can you tell me how can I add currency prefix here?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
87 | |
81 | |
53 | |
38 | |
35 |