Forum Discussion

Haidannx's avatar
Haidannx
Icon for Helper I rankHelper I
6 years ago
Solved

CANT VISUALIZE DATA ON POWERBI

Hello guys, i have a dataset like this and i don`t know how to visualize the total fare of each airlines in the dataset because some customers didn`t pick the same airlines for their travel. (total fare = inbound fare + outbound fare). 

 

Thanks in advance

  • Hi Haidannx ,

    You need to create two calculated columns:

    inb = 'Table'[Inbound fare]*'Table'[number of Adult]
    out = 'Table'[Outbound fare]*'Table'[number of Adult]

    Then create a calculated table:

    Table2 = VALUES('Table'[Outbound airline])

    Finally, create the following measure:

    in-ou =
    VAR _in =
        IF (
            HASONEVALUE ( 'Table2'[column] ),
            CALCULATE (
                SUM ( 'Table'[inb] ),
                FILTER ( 'Table', 'Table'[Inbound airline] = MIN ( 'Table2'[column] ) )
            ),
            SUMX (
                'Table2',
                CALCULATE (
                    SUM ( 'Table'[inb] ),
                    FILTER ( 'Table', 'Table'[Inbound airline] = MIN ( 'Table2'[column] ) )
                )
            )
        )
    VAR _ou =
        IF (
            HASONEVALUE ( 'Table2'[column] ),
            CALCULATE (
                SUM ( 'Table'[out] ),
                FILTER ( 'Table', 'Table'[Outbound airline] = MIN ( 'Table2'[column] ) )
            ),
            SUMX (
                'Table2',
                CALCULATE (
                    SUM ( 'Table'[out] ),
                    FILTER ( 'Table', 'Table'[Outbound airline] = MIN ( 'Table2'[column] ) )
                )
            )
        )
    RETURN
        _in + _ou
        )
    )

    Results are as follows:

    Here is a demo, please try it:

    https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/ETcG0tSFs0dHj5lo1M4_4lsBXE-ev_9JZwEhUhCimv5zUQ?e=Rw9G2N 

    Best Regards,

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

     

     

2 Replies

  • Hi Haidannx ,

    You need to create two calculated columns:

    inb = 'Table'[Inbound fare]*'Table'[number of Adult]
    out = 'Table'[Outbound fare]*'Table'[number of Adult]

    Then create a calculated table:

    Table2 = VALUES('Table'[Outbound airline])

    Finally, create the following measure:

    in-ou =
    VAR _in =
        IF (
            HASONEVALUE ( 'Table2'[column] ),
            CALCULATE (
                SUM ( 'Table'[inb] ),
                FILTER ( 'Table', 'Table'[Inbound airline] = MIN ( 'Table2'[column] ) )
            ),
            SUMX (
                'Table2',
                CALCULATE (
                    SUM ( 'Table'[inb] ),
                    FILTER ( 'Table', 'Table'[Inbound airline] = MIN ( 'Table2'[column] ) )
                )
            )
        )
    VAR _ou =
        IF (
            HASONEVALUE ( 'Table2'[column] ),
            CALCULATE (
                SUM ( 'Table'[out] ),
                FILTER ( 'Table', 'Table'[Outbound airline] = MIN ( 'Table2'[column] ) )
            ),
            SUMX (
                'Table2',
                CALCULATE (
                    SUM ( 'Table'[out] ),
                    FILTER ( 'Table', 'Table'[Outbound airline] = MIN ( 'Table2'[column] ) )
                )
            )
        )
    RETURN
        _in + _ou
        )
    )

    Results are as follows:

    Here is a demo, please try it:

    https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/ETcG0tSFs0dHj5lo1M4_4lsBXE-ev_9JZwEhUhCimv5zUQ?e=Rw9G2N 

    Best Regards,

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