cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IliasKatsis
Frequent Visitor

Check if some ids are included in a group of other with a specific date range.

Hello,

IliasKatsis_0-1658323751189.png

The first screenshot is the transaction table with every single one. The last column concerns the campaign that the coupon id of the transaction is included 

IliasKatsis_1-1658323853698.png

The second screenshot gives us all the details about every single campaign and their coupons. Each campaign has a unique id and has some coupons with their ids. Some coupon id can be found in more than one campaigns.

 

The case that i want help is that i want to create a new column that shows the current campaign of every single transaction.

The first condition is the the transcation date is between the start and end date of every campaign and the second condition is that the coupon id of the transaction must be inside the group of ids of its spesific campaign 

I tried this 

 
Current Camp = maxx(filter('Campaign details', Transactions[Transaction Date] >= 'Campaign details'[Start Date] && Transactions[Transaction Date]<= 'Campaign details'[End Date] && Transactions[coupon_id] in VALUES('Campaign details'[Coupon ID])), 'Campaign details'[Descr])
 
But it did not work.
Please help! thank you!

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @IliasKatsis ,

According to your description, I create a sample to reproduce your problem.

Transactions table:

vkalyjmsft_0-1658813923991.png

Campaign details table:

vkalyjmsft_1-1658813965451.png

In your formula, the Transactions[coupon_id]inVALUES ('Campaign details'[Coupon ID]) can only indicate that [coupon_id] is listed in the Coupon ID of the entire Campaign details table, but cannot be assigned to the current campaign, modify it to:

Current Camp =
MAXX (
    FILTER (
        'Campaign details',
        Transactions[Transaction Date] >= 'Campaign details'[Start Date]
            && Transactions[Transaction Date] <= 'Campaign details'[End Date]
            && Transactions[coupon_id]
                IN SELECTCOLUMNS (
                    FILTER (
                        'Campaign details',
                        'Campaign details'[Campaign ID] = EARLIER ( 'Campaign details'[Campaign ID] )
                    ),
                    "Coupon", 'Campaign details'[Coupon ID]
                )
    ),
    'Campaign details'[Descr]
)

Get the correct result:

vkalyjmsft_2-1658814587802.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

3 REPLIES 3
v-yanjiang-msft
Community Support
Community Support

Hi @IliasKatsis ,

According to your description, I create a sample to reproduce your problem.

Transactions table:

vkalyjmsft_0-1658813923991.png

Campaign details table:

vkalyjmsft_1-1658813965451.png

In your formula, the Transactions[coupon_id]inVALUES ('Campaign details'[Coupon ID]) can only indicate that [coupon_id] is listed in the Coupon ID of the entire Campaign details table, but cannot be assigned to the current campaign, modify it to:

Current Camp =
MAXX (
    FILTER (
        'Campaign details',
        Transactions[Transaction Date] >= 'Campaign details'[Start Date]
            && Transactions[Transaction Date] <= 'Campaign details'[End Date]
            && Transactions[coupon_id]
                IN SELECTCOLUMNS (
                    FILTER (
                        'Campaign details',
                        'Campaign details'[Campaign ID] = EARLIER ( 'Campaign details'[Campaign ID] )
                    ),
                    "Coupon", 'Campaign details'[Coupon ID]
                )
    ),
    'Campaign details'[Descr]
)

Get the correct result:

vkalyjmsft_2-1658814587802.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

Thank you so much!! Everything is running !! You made my day !!

lbendlin
Super User
Super User

You use INTERSECT() for this.

 

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to assist you. I cannot use screenshots of your source data.

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors