Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
jnn4282
Helper II
Helper II

create column or measure to Sum the number of used coupon based on type

https://we.tl/t-SE8z9hLbj7

 

I would like to request help.

The attached date is my file. We give coupons to the registered guests from time to time.

As a data type is remarked as give or use for analysis.

Suppose for the month of January how many BD coupon was used? can be calculated as

BD(Use) = calculate(Distinctcount('table'[CustomerID]),(Table[CouponName]=BD),Table[CouponType] ="use")
 
I want to calculate estimated sales(assumption) that if a customer uses the BD coupon they spend around 15 dollars if the Lunch coupon is used spend 20 dollars and the appetizer  10 dollars.
 
Are there any Hints!
Your support will be highly appreciated.
Result expected will be if 10 BD coupons are used expected sales will be 150 dollors for entire months.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jnn4282 ,

 

If you want to calculate the total used coupon of each CustomerID, each Coupon Name and each YearMonth , please try:

Coupon Count =
CALCULATE (
    COUNTROWS ( 'テーブル2' ),
    FILTER (
        'テーブル2',
        [CustomerID] = MAX ( 'テーブル2'[CustomerID] )
            && [coupon Name] = MAX ( 'テーブル2'[coupon Name] )
            && YEAR ( 'テーブル2'[UsedDate] ) = YEAR ( MAX ( 'テーブル2'[UsedDate] ) )
            && MONTH ( 'テーブル2'[UsedDate] ) = MONTH ( MAX ( 'テーブル2'[UsedDate] ) )
            && [coupon Type] = "use"
    )
)
Total Coupon =
SWITCH (
    MAX ( 'テーブル2'[coupon Name] ),
    "BD", 15,
    "Lunch", 20,
    "Appetizer", 10,
    "Drink", 5
) * [Coupon Count]

Output:

 

Eyelyn9_0-1655085411462.png

Or if you are still confused about it, please provide me with more details about your expected output to help us clarify your scenario.

Refer to:

How to Get Your Question Answered Quickly - Microsoft Power BI Community

 

 

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @jnn4282 ,

 

If you want to calculate the total used coupon of each CustomerID, each Coupon Name and each YearMonth , please try:

Coupon Count =
CALCULATE (
    COUNTROWS ( 'テーブル2' ),
    FILTER (
        'テーブル2',
        [CustomerID] = MAX ( 'テーブル2'[CustomerID] )
            && [coupon Name] = MAX ( 'テーブル2'[coupon Name] )
            && YEAR ( 'テーブル2'[UsedDate] ) = YEAR ( MAX ( 'テーブル2'[UsedDate] ) )
            && MONTH ( 'テーブル2'[UsedDate] ) = MONTH ( MAX ( 'テーブル2'[UsedDate] ) )
            && [coupon Type] = "use"
    )
)
Total Coupon =
SWITCH (
    MAX ( 'テーブル2'[coupon Name] ),
    "BD", 15,
    "Lunch", 20,
    "Appetizer", 10,
    "Drink", 5
) * [Coupon Count]

Output:

 

Eyelyn9_0-1655085411462.png

Or if you are still confused about it, please provide me with more details about your expected output to help us clarify your scenario.

Refer to:

How to Get Your Question Answered Quickly - Microsoft Power BI Community

 

 

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

@Anonymous 

I appreciate your help. Your explanation was very easy to understand.
I am weak on nesting the function. You made my day.

Thank you so much.

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.