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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors