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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
JustinDoh1
Post Prodigy
Post Prodigy

Need some help with Date (bridge) table for drop down menu

I am trying to make my Date table work by possibly adding a column (or possibly a logic) so that I could Sort properly.

 

I have uploaded my PowerBI file here.

 

As you can see on the bottom screenshot, the lastest "New Processing Date" is May 2024.

I have pulled data from SQL, and it is a varchar data type so that I could show "Current = ".

 

JustinDoh1_0-1719104456385.png

The issue is that since this is Varchar data type, not a Date type, sorting is alphabetical.

I would like to display "New Processing Date" as Date asc.

 

How do I go about fixing this Date table?

 

Currently, I used Dax to combine two fields from two tables together to create a Date table called "Date Bridge", and it is used for the drop down menu of visual for "New Processing Date".

 

    Date Bridge = DISTINCT(union(all('Table_1'[New Processing Date]),all(Table_2[New Processing Date])))
 
JustinDoh1_2-1719104815406.png

 

Is there a way to add a new column in "Date Bridge" table and sort by "Processing Date" since this column is a date column?

 

Does Date table only allow one column? 

 

I am trying to utilize having a separate a Date table "Date Bridge" for the design of this visual instead of using "New Processing Date" column from Table_1 or Table_2. 

But, if there is no other way to sort properly, I guess I would have to use "New Processing Date" from either Table_1 or Table_2, but I don't think that is a good design, right?

 

 

 

1 ACCEPTED SOLUTION
DataNinja777
Super User
Super User

Hi @JustinDoh1 ,

There are multiple ways to achive your required sort order and one of them is to use the calculated calendar table and summarize it for the month year field, and then sort "mmmm yyyy" field which was alphabetically sorted originally by "yyyy-mm" to ensure that the sort order respects numerical month order instead of alphabetical sort order.  

A calculated calendar table with month granularity can be produced by the following dax formula.  

Calendar month =
SUMMARIZE (
    ADDCOLUMNS (
        CALENDAR ( DATE ( 2022, 1, 1 ), DATE ( 2024, 12, 31 ) ),
        "yyyy-mm", FORMAT ( [Date], "yyyy-mm" ),
        "mmm-yyyy", FORMAT ( [Date], "mmm-yyyy" ),
        "mmmm yyyy", FORMAT ( [Date], "mmmm yyyy" )
    ),
    [mmm-yyyy],
    [mmmm yyyy],
    [yyyy-mm]
)

DataNinja777_0-1719124083724.png

Then, you can create a calculated column in the calculated calendar table to identify the Current month from your fact table.  

You can fix the sorting issue of "mmmm yyyy" by using the following user interface in the table view.  

DataNinja777_1-1719124258267.png

The resultant output shows the properly sorted mmmm yyyy field which identifies Current month properly.

DataNinja777_2-1719124354304.png

This is one of many ways to achive your required output. I attach an example pbix file.  

Best regards,

View solution in original post

3 REPLIES 3
JustinDoh1
Post Prodigy
Post Prodigy

@DataNinja777  Thank you so much for your help. I think this would work. Let me take a deeper look later.

As far as relationship with two other tables (Table_1 & Table_2), can I make them Active? Any consequences?

JustinDoh1_0-1719354866281.png

 

@DataNinja777 Thanks for your contribution on this thread.

Hi @JustinDoh1 ,

You can set the relationship between Calendar month and Table_1 and Calendar month and Table_2 as active. The important thing to note here is that there can only be one active relationship between two tables. When discussing any potential consequences, could you clarify which side you are referring to? Is it related to data display or another aspect?

Create and manage relationships in Power BI Desktop 

Best Regards

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

Hi @JustinDoh1 ,

There are multiple ways to achive your required sort order and one of them is to use the calculated calendar table and summarize it for the month year field, and then sort "mmmm yyyy" field which was alphabetically sorted originally by "yyyy-mm" to ensure that the sort order respects numerical month order instead of alphabetical sort order.  

A calculated calendar table with month granularity can be produced by the following dax formula.  

Calendar month =
SUMMARIZE (
    ADDCOLUMNS (
        CALENDAR ( DATE ( 2022, 1, 1 ), DATE ( 2024, 12, 31 ) ),
        "yyyy-mm", FORMAT ( [Date], "yyyy-mm" ),
        "mmm-yyyy", FORMAT ( [Date], "mmm-yyyy" ),
        "mmmm yyyy", FORMAT ( [Date], "mmmm yyyy" )
    ),
    [mmm-yyyy],
    [mmmm yyyy],
    [yyyy-mm]
)

DataNinja777_0-1719124083724.png

Then, you can create a calculated column in the calculated calendar table to identify the Current month from your fact table.  

You can fix the sorting issue of "mmmm yyyy" by using the following user interface in the table view.  

DataNinja777_1-1719124258267.png

The resultant output shows the properly sorted mmmm yyyy field which identifies Current month properly.

DataNinja777_2-1719124354304.png

This is one of many ways to achive your required output. I attach an example pbix file.  

Best regards,

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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