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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
DDL1976
Frequent Visitor

Help with a DAX Switch (Filter with a Related Table)

Hi there,

 

I have a DAX function that is working, but I want to extend the logic so its Dynamic rather than hard coded..

I have a slicer that selects 1 of the 2 options in the table below 'Report up to'

Then a little piece of DAX to feed the Switch Function.

Select Report To = MIN('DimReport To'[Switch])

 

Here is the DAX containing the SWITCH logic

Report To = 
  SWITCH([Select Report To],
    1, Calculate (sum(FactActualAndPlans[Value]), Filter(FactActualAndPlans, RELATED(DimPeriod[Period End Date]) <= DATE(2020,4,30))) ,
    2, SUM(FactActualAndPlans[Value])

 

In the first option of the switch I need the date of 2020,04,30 to reference the date in the first row of table below called ('DimReport To') that can periodically change. (This date could be placed in a different table if that makes it more simple?)

Period End Date		Switch		Type	                  
28 February 2021	1			Finalised Periods Only	  
31 December 2999	2			All Periods	          

 

 

I hope I have explained it clearly enough...

Thanks in advance for the help of the community!!!

1 REPLY 1
amitchandak
Super User
Super User

@DDL1976 , Something like this

 

SWITCH(True()
[Select Report To] =1 && RELATED(DimPeriod[Period End Date]) <= DATE(2020,4,30) , Calculate (sum(FactActualAndPlans[Value]), Filter(FactActualAndPlans, RELATED(DimPeriod[Period End Date]) <= DATE(2020,4,30))) ,
[Select Report To] = 2, SUM(FactActualAndPlans[Value])
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.