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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Can I add conditional prefix ($ or €) in a sales visual according to the filter??

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?

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@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.

View solution in original post

7 REPLIES 7
SpartaBI
Community Champion
Community Champion

@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
Not applicable

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.

Anonymous
Not applicable

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! ":) 

SpartaBI
Community Champion
Community Champion

@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

Anonymous
Not applicable

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?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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