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, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
likhithar
Helper III
Helper III

How to get Dimension Column based on the selected time period in DAX

Hello All,

I have a Dimension table where Dimension ID will be dynamic(may in one month few dimension id may added and in another monther month few dimension id may be removed) and it will maintained with YYYYMM Column. 

likhithar_0-1639201026361.png

From the above Image, If I relate Dim Table and Fact Table , the relationship will be Many-Many, to avoid that I created Bridge Table with DAX 

Bridge Table = DISTINCT(DimTable[Town ID])

The other way I tried for Bridge Table is

Bridge Table = CALCULATETABLE(DISTINCT(DimTable[Town ID]),FILTER(DIMTABLE,DIMTABLE[YYYYMM]=MAX(DIMTABLE[YYYYMM])

With the abovre approach , I'm getting MAX month in DimTable Dimension values only for every month in Bridge Table

And the I did Modeling as below

likhithar_1-1639201255086.png

Now my requirement is if One Town ID is removed in Dim Table for a month (Ex:Town ID 2 for 202109 in Dim Table is removed  , Bridge it should get updated(there should not be town ID 2 in Bridge Table for 202109) .If I select (202108, town ID 2 should be there in Bridge Table as it was there in Dim Table).

How to achieve this scenario, I need the Help??

Or suggest any other approach to achieve this??TIA

@amitchandak @Greg_Deckler 

 

 

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

Hi @likhithar 

We couldn't create a dynamic caclualted table filtered by slicer or filter like a measure. Here I suggest you to solve your problem by change relationship direction or create a filter measure.

1. Change relationship direction

1.png

Result is as below.

YYYYMM = 202109

1.png

YYYYMM = 202108

2.png

2. Create a filter measure

1.png

Measure = 
VAR _Bridge = VALUES(DimTable[Town ID])
RETURN
IF(MAX('Bridge Table'[Town ID]) IN _Bridge,1,0)

 YYYYMM = 2021091.png

YYYYMM = 202108

2.png

Best Regards,
Rico Zhou

 

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

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @likhithar 

We couldn't create a dynamic caclualted table filtered by slicer or filter like a measure. Here I suggest you to solve your problem by change relationship direction or create a filter measure.

1. Change relationship direction

1.png

Result is as below.

YYYYMM = 202109

1.png

YYYYMM = 202108

2.png

2. Create a filter measure

1.png

Measure = 
VAR _Bridge = VALUES(DimTable[Town ID])
RETURN
IF(MAX('Bridge Table'[Town ID]) IN _Bridge,1,0)

 YYYYMM = 2021091.png

YYYYMM = 202108

2.png

Best Regards,
Rico Zhou

 

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

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 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.

October NL Carousel

Fabric Community Update - October 2024

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