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
danyal1990
New Member

Split Dimension in Bar Chart and Show Combined Calculated Values

Hi All,

 

Is there any way in DAX to split values and show them as calculated? as I don't want to change in my Data Model.

 

Please guide.

 

Problem:

danyal1990_0-1648805282606.png

 

Requirement:

danyal1990_1-1648805461125.png

Regards

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @danyal1990 ,

 

Not sure about how you would like to split the rows “Value-2:Value-1”, so I do it by random. You may need do a little change to the following DAX formula to fulfill your needs.

Here are the sample data used.

vcazhengmsft_0-1649163057402.png

 

Create a Calculated column to complete the split.

Split =
VAR rows_need_split =
    CALCULATE (
        COUNT ( 'Table'[Response] ),
        CONTAINSSTRING ( 'Table'[Response], ":" )
    )
VAR mid_ =
    RAND()* rows_need_split
VAR half = rows_need_split / 2
VAR res =
    IF (
        mid_ > 0
            && mid_ <= half,
        LEFT ( 'Table'[Response], 7 ),
        MID ( 'Table'[Response], 9, 8 )
    )
RETURN
    IF ( CONTAINSSTRING ( 'Table'[Response], ":" ), res, 'Table'[Response] )

 

And use the Calculated column above to create the visual. The result will look like this.

vcazhengmsft_1-1649163057404.png

 

vcazhengmsft_2-1649163057407.png

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

5 REPLIES 5
v-cazheng-msft
Community Support
Community Support

Hi @danyal1990 ,

 

Not sure about how you would like to split the rows “Value-2:Value-1”, so I do it by random. You may need do a little change to the following DAX formula to fulfill your needs.

Here are the sample data used.

vcazhengmsft_0-1649163057402.png

 

Create a Calculated column to complete the split.

Split =
VAR rows_need_split =
    CALCULATE (
        COUNT ( 'Table'[Response] ),
        CONTAINSSTRING ( 'Table'[Response], ":" )
    )
VAR mid_ =
    RAND()* rows_need_split
VAR half = rows_need_split / 2
VAR res =
    IF (
        mid_ > 0
            && mid_ <= half,
        LEFT ( 'Table'[Response], 7 ),
        MID ( 'Table'[Response], 9, 8 )
    )
RETURN
    IF ( CONTAINSSTRING ( 'Table'[Response], ":" ), res, 'Table'[Response] )

 

And use the Calculated column above to create the visual. The result will look like this.

vcazhengmsft_1-1649163057404.png

 

vcazhengmsft_2-1649163057407.png

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

tamerj1
Super User
Super User

Manage it based on what? There must be some criteria 

Yes, I just want to split the Response and want DAX to calculate the Responses as shown in picture.

I just edited the picture on my own not done any calculation.

Should we need to do a Group By or anything else? guide please
Thanks

 

tamerj1
Super User
Super User

Hi @danyal1990 
Is this a simple count? How did you know that 2 goes for Value2 and 1 goes for Value1?

Hi tamerj1,


Yes, currently it is simple count of the response.

 

If we split this response through DAX then it will automatically manage it or we need to change it? 

 

danyal1990_0-1648825059004.png

 

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.

Top Solution Authors