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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.