Forum Discussion

venkataramana's avatar
venkataramana
Regular Visitor
5 years ago
Solved

Need a measure for Line chart in Power BI

Hi, I am creating a line chart in Power BI, with 'month name', 'Company' and 'No of transcations' fields.

          1) 'Month name' - it should show all the months for selected year.

               ( Ex: if it is '2021' it should be 'Jan to Aug (current month), if it is '2020', it should be 'Jan to Dec').

          2) Company - It shows all the companies names. Company names may increase or decrease each year.

          3) 'No of transcations' - It shows the number of transactions happend for each company for each year and month.

I need a measure for line chart, and it should divide 100% to all companies for each month. If you are confused with my words, please look at the attached screenshot.

 Please help on this.

Thanks in advance. 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi venkataramana ,

    I created a sample pbix file(see attachment) for you, please check whether that is what you want.

    % measure = 
    VAR _inditrans =
        SUM ( 'Transactions'[No of transactions] )
    VAR _permonthtrans =
        CALCULATE (
            SUM ( 'Transactions'[No of transactions] ),
            FILTER (
                ALLSELECTED ( 'Transactions' ),
                'Transactions'[Date] = SELECTEDVALUE ( 'Transactions'[Date] )
            )
        )
    RETURN
        DIVIDE ( _inditrans, _permonthtrans, 0 )

    Best Regards

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi venkataramana ,

    I created a sample pbix file(see attachment) for you, please check whether that is what you want.

    % measure = 
    VAR _inditrans =
        SUM ( 'Transactions'[No of transactions] )
    VAR _permonthtrans =
        CALCULATE (
            SUM ( 'Transactions'[No of transactions] ),
            FILTER (
                ALLSELECTED ( 'Transactions' ),
                'Transactions'[Date] = SELECTEDVALUE ( 'Transactions'[Date] )
            )
        )
    RETURN
        DIVIDE ( _inditrans, _permonthtrans, 0 )

    Best Regards