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
PowerVisualBI
Helper I
Helper I

How to filter two different dates in two different tables in one slicer

I want to filter [out_of_stock].[qty] and [normal price].[price] by using 2 different dates in each table.
The date I want to use:
1. [normal price].[update_at]
2. [out_of_stock].[created_at]

Is it possible if I only use one filter with the two date inputs above, but it directly affects two values, namely [out_of_stock].[qty] and [normal price].[price]?

Screenshot 2022-07-28 062905.png

 

Here is the link to the document: https://drive.google.com/drive/folders/1FRS9z4Zc7booJJ-KsxMUB_-HEWmMnJmJ?usp=sharing 

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

Hi @PowerVisualBI ,

 

You should first create a new date table to combine two dates in different tables.

 

But I find that in your “harga_normal” table, the date column has something wrong, perhaps there is an error in the data, I have sieved out the zero dates for ease of calculation.

vmengzhumsft_0-1659404184624.png

Table = DISTINCT( UNION(VALUES(out_of_stock[created_at]),calculatetable (VALUES('harga_normal'[updated_at]),FILTER('harga_normal',harga_normal[updated_at]<> "0000-00-00 00:00:00") )))

 

And then create two measure to achieve what you want:

 

QTY = CALCULATE(SUM(out_of_stock[qty]),FILTER('out_of_stock',[created_at]>=MIN('Table'[created_at])&& out_of_stock[created_at]<=MAX('Table'[created_at])))

Harga = CALCULATE(SUM(harga_normal[harga]),FILTER('harga_normal',[created_at]>=MIN('Table'[created_at])&& harga_normal[created_at]<=MAX('Table'[created_at])))

For more details you can view this file.

 

Best regards,

Community Support Team Selina zhu

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

2 REPLIES 2
v-mengzhu-msft
Community Support
Community Support

Hi @PowerVisualBI ,

 

You should first create a new date table to combine two dates in different tables.

 

But I find that in your “harga_normal” table, the date column has something wrong, perhaps there is an error in the data, I have sieved out the zero dates for ease of calculation.

vmengzhumsft_0-1659404184624.png

Table = DISTINCT( UNION(VALUES(out_of_stock[created_at]),calculatetable (VALUES('harga_normal'[updated_at]),FILTER('harga_normal',harga_normal[updated_at]<> "0000-00-00 00:00:00") )))

 

And then create two measure to achieve what you want:

 

QTY = CALCULATE(SUM(out_of_stock[qty]),FILTER('out_of_stock',[created_at]>=MIN('Table'[created_at])&& out_of_stock[created_at]<=MAX('Table'[created_at])))

Harga = CALCULATE(SUM(harga_normal[harga]),FILTER('harga_normal',[created_at]>=MIN('Table'[created_at])&& harga_normal[created_at]<=MAX('Table'[created_at])))

For more details you can view this file.

 

Best regards,

Community Support Team Selina zhu

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

amitchandak
Super User
Super User

@PowerVisualBI , If you want two dates to use the same date slicer. hen you should create a common date table and join with dates (dates should not have timestamps)

One join will be inactive , which you can activate using userelationship

 

 

Created Date = datesvalue([created_at]) //in case date is with time

 

https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in...

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.

Top Solution Authors