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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JaySharma
Frequent Visitor

How to make a custom date table for filtering using dates from different tables?

I have 3 tables; let's call them table A B and C. I have dates in those tables: DateA, DateB and DateC.

I need to use these as filters using two slicers. one as a dropdown to choose between the names DateA, DateB, or DateC, and the second slicer, the beteween date slicer, should populate the dates from the correct table. 

 

My idea was to create a fourth table with a DateType column with the remaining 3 dates. Something like this, but I'm unable to achieve it using DAX for a table. 

This is something I need to achieve: 

 

DateTypeDate1Date2Date3
Date1Date1 ValuesNULLNULL
Date1Date1 ValuesNULLNULL
Date1Date1 ValuesNULLNULL
Date1Date1 ValuesNULLNULL
Date2NULLDate2 ValuesNULL
Date2NULLDate2 ValuesNULL
Date2NULLDate2 ValuesNULL
Date3NULLNULLDate3 Values
Date3NULLNULLDate3 Values

The idea after that is to link up these Date colums to their respective original tables.

1 ACCEPTED SOLUTION

hello @JaySharma 

 

please check if this accomodate your need.

 

1. create new table (fourth table as you mentioned) using UNION to combine all date value

DateType =
var _Union = UNION('Date A','Date B','Date C')
Return
SELECTCOLUMNS(_Union,"Date",[Date A])

Irwan_0-1721616675112.png

 

2. create calculated column for Date1

Date1 = MAXX(FILTER('Date A','Date A'[Date A]='DateType'[Date]),'Date A'[Date A])
 
3. create calculated column for Date2
Date2 = MAXX(FILTER('Date B','Date B'[Date B]='DateType'[Date]),'Date B'[Date B])
 
4. create calculated column for Date3 
Date3 = MAXX(FILTER('Date C','Date C'[Date C]='DateType'[Date]),'Date C'[Date C])
 
Result: 
Irwan_1-1721616785443.png

 

Hope this will help you.

Thank you.

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

First and foemost, you should right click on the first column in Power Query and select "Unpivot Other Columns".  Then create a Calendar Table.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
AllisonKennedy
Super User
Super User

@JaySharma  do you have a DimDate table? It might make things a little simpler for what you're trying to do - you could then create a measure that shows the max or selectedvalue of the date and show all three at once.

 

If you're wanting a slicer for users to be able to select only A, B or C, then using calculation groups and / or Field Parameters may help. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@AllisonKennedy I do have the DimDate table, but I doubt if that would serve any purpose. I need 2 slicers, 1 to select the date type (Date of purchase/date of delivery/date of return) something like that and then the second between-date slicer to filter the data based on the selected date type. 

 

I have a star schema and I brought in all the dates to the central fact table to make stuff easier as the dates were coming from different tables. I tried creating a new table with dax wigh columns (Date type | DateType1 | DateType2 | DateType3) but I can't connect these three columns to three source columns in the fact table.

 

hello @JaySharma 

 

please check if this accomodate your need.

 

1. create new table (fourth table as you mentioned) using UNION to combine all date value

DateType =
var _Union = UNION('Date A','Date B','Date C')
Return
SELECTCOLUMNS(_Union,"Date",[Date A])

Irwan_0-1721616675112.png

 

2. create calculated column for Date1

Date1 = MAXX(FILTER('Date A','Date A'[Date A]='DateType'[Date]),'Date A'[Date A])
 
3. create calculated column for Date2
Date2 = MAXX(FILTER('Date B','Date B'[Date B]='DateType'[Date]),'Date B'[Date B])
 
4. create calculated column for Date3 
Date3 = MAXX(FILTER('Date C','Date C'[Date C]='DateType'[Date]),'Date C'[Date C])
 
Result: 
Irwan_1-1721616785443.png

 

Hope this will help you.

Thank you.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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