Forum Discussion

ljx0648's avatar
ljx0648
Icon for Helper III rankHelper III
2 years ago
Solved

create a calculated measure or column based on different conditions

Hi guys,   Below is the data I have: Customer Count of Plan Purchased Type Frequency Description Amount A 1 Weekly 1 Pay every 1 week 10 B 2 Weekly 2 Pay every 2 week 10 ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi ljx0648 ,

    I create a table as you mentioned.

    Then I create a calculated column and here is the DAX code.

    Column = 
    SWITCH (
        TRUE (),
        'Table'[Type] = "Weekly"
            && 'Table'[Frequency] = 1,
            'Table'[Amount] * 'Table'[Count of Plan Purchased] * 4,
        'Table'[Type] = "Weekly"
            && 'Table'[Frequency] = 2,
            'Table'[Amount] * 'Table'[Count of Plan Purchased] * 2,
        'Table'[Type] = "Monthly"
            && 'Table'[Frequency] = 1,
            'Table'[Amount] * 'Table'[Count of Plan Purchased] * 1,
        'Table'[Type] = "Monthly"
            && 'Table'[Frequency] > 1,
            'Table'[Amount] * 'Table'[Count of Plan Purchased] / 'Table'[Frequency],
        BLANK ()
    )

    Finally you will get what you want.

     

     

     

    Best Regards

    Yilong Zhou

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