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

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.

Reply
Harpreet1405_12
Helper II
Helper II

Dynamic Change of data type by filtered value

Hello,

 

I want to create a pie chart that will display the data with different data types when selecting different parameters in same pie chart, i have pivoted column.

7 REPLIES 7
v-xinruzhu-msft
Community Support
Community Support

Hi @Harpreet1405_12 

You can create measure and use switch function.

e.g 

SWITCH(TRUE(),para1,Datatype1,para2,Datatype2,,,,,)

You can refer to tje following link to know more about switch() function

SWITCH function (DAX) - DAX | Microsoft Learn

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much for your response, I want to switch to the datatype in a pivoted column, for example from the whole number datatype to the currency data type in the pie chart or other visualization. the switch function does not allow me to enter the datatype function. The Average hourly rate in the second column should be in fixed decimal with currency datatype whereas "Headcount" and "Number of Contracts Processed" should be in 

 

2017-2018Headcount# PT Contracts161
2017-2018Headcount# Sessional Contracts49
2017-2018Headcount# Partial Load Contracts51
2018-2019Headcount# PT Contracts168
2018-2019Headcount# Sessional Contracts35
2018-2019Headcount# Partial Load Contracts73
2019-2020Headcount# PT Contracts176
2019-2020Headcount# Sessional Contracts35
2019-2020Headcount# Partial Load Contracts85
2020-2021Headcount# PT Contracts193
2020-2021Headcount# Sessional Contracts30
2020-2021Headcount# Partial Load Contracts70
2021-2022Headcount# PT Contracts199
2021-2022Headcount# Sessional Contracts24
2021-2022Headcount# Partial Load Contracts90
2017-2018Number of contract processed# PT Contracts225
2017-2018Number of contract processed# Sessional Contracts131
2017-2018Number of contract processed# Partial Load Contracts196
2018-2019Number of contract processed# PT Contracts243
2018-2019Number of contract processed# Sessional Contracts91
2018-2019Number of contract processed# Partial Load Contracts202
2019-2020Number of contract processed# PT Contracts260
2019-2020Number of contract processed# Sessional Contracts105
2019-2020Number of contract processed# Partial Load Contracts227
2020-2021Number of contract processed# PT Contracts296
2020-2021Number of contract processed# Sessional Contracts104
2020-2021Number of contract processed# Partial Load Contracts243
2021-2022Number of contract processed# PT Contracts307
2021-2022Number of contract processed# Sessional Contracts103
2021-2022Number of contract processed# Partial Load Contracts268
2017-2018Average hourly rate# PT Contracts60.25
2017-2018Average hourly rate# Sessional Contracts49.47
2017-2018Average hourly rate# Partial Load Contracts97.89
2018-2019Average hourly rate# PT Contracts95.44
2018-2019Average hourly rate# Sessional Contracts82.93
2018-2019Average hourly rate# Partial Load Contracts82.93
2019-2020Average hourly rate# PT Contracts99.5
2019-2020Average hourly rate# Sessional Contracts90.41
2019-2020Average hourly rate# Partial Load Contracts104.19
2020-2021Average hourly rate# PT Contracts104.07
2020-2021Average hourly rate# Sessional Contracts102.08
2020-2021Average hourly rate# Partial Load Contracts108.05
2021-2022Average hourly rate# PT Contracts106.95
2021-2022Average hourly rate# Sessional Contracts97.05
2021-2022Average hourly rate# Partial Load Contracts108.4

Hi @Harpreet1405_12 

You can use convert() function.

e.g 

Measure = SWITCH(TRUE(),MAX([Column2])="Average hourly rate",CONVERT(SUM([Column4]),CURRENCY),MAX([Column2])="Headcount",CONVERT(SUM([Column4]),STRING))

Output

vxinruzhumsft_0-1677223216137.png

 

vxinruzhumsft_1-1677223222640.png

You can refer to the following link to know more about the function.

CONVERT function (DAX) - DAX | Microsoft Learn

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thank you once again for your valuable response, but this is not showing the values for headcount and the number of contracts processed for the pie chart or table. 

 

The output should be:-

output.pngoutput 2.png

Hi @Harpreet1405_12 

Can you provide the detail data type of  "Number of Contracts Processed" and "Headcount" the information you have offered only display the type of the "Average hourly rate" field.

 

Best Regards!

Yolo Zhu

 

The explanation of the data types is as follows:-

1. Headcount = whole number

2. Number of Contracts processed = Whole number

3. Average Hourly Rate = Currency (dollars)

 

All i want is that pie chart will display the data type based on the filter on column 2.

Hi @Harpreet1405_12 

After testing, the date type changing can be realized in table visual,but cannot be displayed in pie chart. maybe you can try create two mesaures , one measure type is whole number, the other type is currency, then create two pie charts and use bookmark to control when the pie to display, use the bookmark navigation button as slicer. you can refer to the following links.

https://learn.microsoft.com/en-us/power-bi/create-reports/button-navigators?tabs=powerbi-desktop#boo...

Create report bookmarks in Power BI to share insights and build stories - Power BI | Microsoft Learn

 

If you want to display it in table visual, you can refer to the following measure.

Measure = SWITCH(TRUE(),MAX([Column2])="Average hourly rate",FORMAT(SUM([Column4]),"$#.##"),OR(MAX([Column2])="Headcount",MAX([Column2])="Number of contract processed"),CONVERT(SUM([Column4]),INTEGER))

vxinruzhumsft_0-1677567360981.png

 

vxinruzhumsft_1-1677567369153.png

 

vxinruzhumsft_2-1677567376673.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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