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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
PwrBI01
Post Patron
Post Patron

Different formats in switch function

Hi guys,

 

I have used a switch function to create the following table:

Tabla 1.png

 

The switch function I have used is the next one: 

IF(HASONEVALUE('T_M_Tabla indicadores económicos'[Medida]);SWITCH(VALUES('T_M_Tabla indicadores económicos'[Medida]);"Variación prev. año";[Acumulado dos años previos];"% crecimiento";[Acumulado var %];"Importe medio";[Switch importe medio];"% Var importe medio";[Switch importe medio % var];"Variación a fecha";[Acumulado var]))
 
Is there a way to change the formats to get a table similar to the next one:
Tabla 2.png
 
Thanks in advance.
 
Regards.
1 ACCEPTED SOLUTION
Tahreem24
Super User
Super User

@PwrBI01 ,

Create a meaure with the below DAX:

MEASURE = IF(HASONEVALUE('T_M_Tabla indicadores económicos'[Medida]);SWITCH(VALUES('T_M_Tabla indicadores económicos'[Medida]);"Variación prev. año";FORMAT([Acumulado dos años previos],"#.### $");"% crecimiento";FORMAT([Acumulado var %],"Percent");"Importe medio";FORMAT([Switch importe medio],"## $");"% Var importe medio";FORMAT([Switch importe medio % var],"Percent");"Variación a fecha";FORMAT([Acumulado var],"#.### $")))

 

P.S. Just replace the $ sign with Pound sign while writing this dax as per your currency requirement.

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

5 REPLIES 5
Tahreem24
Super User
Super User

@PwrBI01 ,

Create a meaure with the below DAX:

MEASURE = IF(HASONEVALUE('T_M_Tabla indicadores económicos'[Medida]);SWITCH(VALUES('T_M_Tabla indicadores económicos'[Medida]);"Variación prev. año";FORMAT([Acumulado dos años previos],"#.### $");"% crecimiento";FORMAT([Acumulado var %],"Percent");"Importe medio";FORMAT([Switch importe medio],"## $");"% Var importe medio";FORMAT([Switch importe medio % var],"Percent");"Variación a fecha";FORMAT([Acumulado var],"#.### $")))

 

P.S. Just replace the $ sign with Pound sign while writing this dax as per your currency requirement.

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Thank you very much @Tahreem24

 

I made some changes (for no decimals in percentages and for get the local format) and it works. The measure I finally used is the next one:

 

Switch prueba = IF(HASONEVALUE('T_M_Tabla indicadores económicos'[Medida]);SWITCH(VALUES('T_M_Tabla indicadores económicos'[Medida]);"Variación prev. año";FORMAT([Acumulado dos años previos];"#,### €");"% crecimiento";FORMAT([Acumulado var %];"#,### %");"Importe medio";FORMAT([Switch importe medio];"#,### €");"% Var importe medio";FORMAT([Switch importe medio % var];"#,### %");"Variación a fecha";FORMAT([Acumulado var];"#,### €")))
 
Regards.

@PwrBI01  Great!

Yeah, I just shared the possible workaround using Format DAX. It's nice that you changed it accordingly to your needs.

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
amitchandak
Super User
Super User

@PwrBI01 , You have to use calculation groups for that as of now

https://www.sqlbi.com/blog/marco/2020/07/15/creating-calculation-groups-in-power-bi-desktop/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you very much for your answer @amitchandak but I would like to do it in a more easy way.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.