Forum Discussion

pbi_data's avatar
pbi_data
Frequent Visitor
3 years ago
Solved

DAX measure

Hi,

 

I need some help.

 

I have a measure that takes the max of the products for each customer.

products per customer = CALCULATE(MAX('Table'[products_per_customer]))

 

But I want my measure to take the number of products  for each month for every customer, not the max.

I need this measure for  other calculation which a part of the table visual.

 

 

Date

products

products per customer

15 March 2023

10

10

16 March 2023

10

10

1 April 2023

15

15

2 April 2023

15

15

15 March 2020

8

8

 

Any asssitance would be helpful.

Thank you .

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi pbi_data ,

    Please try below steps:
    1. below is my test table

    Table:

    2. create a measure with below dax formula

    Measure =
    VAR cur_date =
        SELECTEDVALUE ( 'Table'[Date] )
    VAR cur_year =
        YEAR ( cur_date )
    VAR cur_month =
        MONTH ( cur_date )
    VAR tmp =
        FILTER (
            ALL ( 'Table' ),
            YEAR ( [Date] ) = cur_year
                && MONTH ( [Date] ) = cur_month
        )
    RETURN
        MAXX ( tmp, [Products] )
    

    3. add a table visual with table fields and measure

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi pbi_data ,

    Please try below steps:
    1. below is my test table

    Table:

    2. create a measure with below dax formula

    Measure =
    VAR cur_date =
        SELECTEDVALUE ( 'Table'[Date] )
    VAR cur_year =
        YEAR ( cur_date )
    VAR cur_month =
        MONTH ( cur_date )
    VAR tmp =
        FILTER (
            ALL ( 'Table' ),
            YEAR ( [Date] ) = cur_year
                && MONTH ( [Date] ) = cur_month
        )
    RETURN
        MAXX ( tmp, [Products] )
    

    3. add a table visual with table fields and measure

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.