- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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 |
C | 3 | Monthly | 1 | Pay every 1 month | 10 |
D | 4 | Monthly | 12 | Pay every 12 month | 10 |
My goal here is calculate the Monthly average paymen of each customer.
The logic I am trying to implement is that
When Type = Weekly and Frequency is 1 (pay every week), then the monthly amount should be = Amount * count of plan purchased * 4 (becauie there are 4 weeks in a month)
When Type = Weekly and Frequency is 2 (pay every 2 week), then the monthly amount should be = Amount * count of plan purchased * 2 (becauie there are 2* 2 weeks in a month)
Whenn Type = Monthly and Frequency is 1, then the monthly amount should be = Amount * count of plan purchased * 1
Whenn Type = Monthly and Frequency > 1, then the monthly amount should be = Amount * count of plan purchased divided frequncy (in the example here the frequency is 12, however, there are 2,3,4 etc in the real data)
May I know if anyone have an idea how to write such logic in a calculated column OR measure?
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @ljx0648 ,
You could look into using a SWITCH function to achieve this in a measure.
https://learn.microsoft.com/en-us/dax/switch-function-dax

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
11-06-2023 06:24 AM | |||
12-08-2023 03:12 PM | |||
07-01-2024 10:29 AM | |||
10-25-2023 03:32 PM | |||
08-02-2023 09:44 PM |
User | Count |
---|---|
84 | |
78 | |
41 | |
40 | |
35 |