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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
IliasKatsis
Helper I
Helper I

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.