Forum Discussion

danyal1990's avatar
danyal1990
Regular Visitor
4 years ago
Solved

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:

 

Requirement:

Regards

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

     

    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.

     

     

    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

5 Replies

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

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

    • danyal1990's avatar
      danyal1990
      Regular Visitor

      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? 

       

       

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Manage it based on what? There must be some criteria 

    • danyal1990's avatar
      danyal1990
      Regular Visitor

      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

       

  • v-cazheng-msft's avatar
    v-cazheng-msft
    Icon for Community Support rankCommunity 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.

     

    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.

     

     

    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