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
jasi
New Member

How to use different Filter criteria per line

Hi,

 

I'm stuck with a problem and hope soemone here can help me out. I treid to simplify the setup to point out the issue.

 

I have a lookup table containign Advertiser / Campaing /start and end date

The data table only has Advertiser date and value. My goal is to get the Values per live campaign (data date is in between start and end lookup date).

 

My idea was to have a a calculated column in the data table indicating whether the line is belonging to a "live" campaign (0/1)It would be soemthing like this in in the filed.

Lookup corrospondind Advertiser in th lookup table, check whether date is within start and end dates, if yes 1 if no check for next line with corrosponding advertiser, cehck dates ...

 

But I was not able to get the proper DAX. Any ideas?  I'm open to other solution as well.

 

Thanks

 

 Capture.PNG

1 ACCEPTED SOLUTION

Hi @jasi,

 

You can create a measure in Lookup Table below. See attched .pbix.

 

Measure = CALCULATE(SUM('Data Table'[Value]),FILTER('Data Table',MAX('Lookup Table'[Advertiser])='Data Table'[Advertiser] && MAX('Lookup Table'[End Date])>='Data Table'[Date] && MAX('Lookup Table'[Start Date])<='Data Table'[Date]))

 

q6.PNG

 

 

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
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

4 REPLIES 4
JordanAWARE
Frequent Visitor

SO assuming i understand what you wanting..

 

the data table you want to add in the Campaign column based on the advertiser and date?

 

make a new calculated column in the data table that does this:

 

Campaign = 

IF ( 'lookup table'[Advertiser] = 'data table'[Advertiser] & 'data table'[Date] >= 'lookup table'[Start Date] &

'data table'[Date] <= 'lookup table'[End Date],

'lookup table'[Campaign],

blank()

)

 

then you can just create a measure to count value total

 

Total = count(value total)

 

then make a table on the report, drag in campaign, advertiser, total 

 

Thanks for your help, but it is not to working for me.

 

I get the error already when PBI should compare the Advertiser fields. It is not doing the many to many compare.

IF ( 'lookup table'[Advertiser] = 'data table'[Advertiser] ,0,1)

 

"This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max"

 

Any other idea?

Hi @jasi,

 

You can create a measure in Lookup Table below. See attched .pbix.

 

Measure = CALCULATE(SUM('Data Table'[Value]),FILTER('Data Table',MAX('Lookup Table'[Advertiser])='Data Table'[Advertiser] && MAX('Lookup Table'[End Date])>='Data Table'[Date] && MAX('Lookup Table'[Start Date])<='Data Table'[Date]))

 

q6.PNG

 

 

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks a lot @v-qiuyu-msft

This is working out fine for this example. I was able to recreate it.

I will now try to apply your solution to the more complex live data!

 

cheers

jasi

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.