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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
JamesAH
Regular Visitor

Dynamic Filtering when using Field Parameters

I pretty sure I have hit a dead end after many hours of research and testing but I'd love it if someone can help me solve this one. My goal is to use a Sankey diagram to show changes in data over time. The data is opportunites from a CRM and I want to show the movment in stages. Currently the data is pulled every week and appended to a table with the extraction date. I then pivot this table on the extraction date by stage so I get a column for each extraction date with the stage when it was extracted. I'm then using DAX to dynamically build my Parameter Fileld as I want the user to be able to select two dates (columns) that are then used for the Sankey. As the data is updated every week, it can't be hard coded. This allows me to use the two parameter field to feed into the Sankey Diargram like this: 

Screenshot 2025-04-29 at 13.39.00.png

 Now the bit I'm stuck on - The issue with this visual is that it shows data when there is no change i.e. records that were in one stage and are still in that stage. I want to be able to filter these out. I've tried to use a measure that compares the two cols when there are slected but the issue is that I can't get it to work as I need. The approach below as an exapmple works but my issue is that the dates are hard coded and every time them data updates with a new extract, this code needs updating too. 

 

ChangeFlag = 
VAR SourceStatus = 
    SWITCH(
        TRUE(),
        SELECTEDVALUE('ParameterTable'[Parameter]) = "'InputTable'[18/04/2025]", 'InputTable'[18/04/2025],
        SELECTEDVALUE('ParameterTable'[Parameter]) = "'InputTable'[19/04/2025]", 'InputTable'[19/04/2025],
        SELECTEDVALUE('ParameterTable'[Parameter]) = "'InputTable'[20/04/2025]", 'InputTable'[20/04/2025],
        BLANK()
    )
VAR CurrentStatus = 'InputTable'[YourStaticDestinationColumn] 
RETURN
IF(
    SourceStatus <> CurrentStatus,
    1,
    BLANK()
)

 

Is there any way to make the above code dynamic and biuld based on the number of extraction dates? Or are there other ways to do this? Thanks, 

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@JamesAH , Try using

Create a Parameter Table: Ensure you have a parameter table that allows users to select the two dates dynamically.

Dynamic Column Selection: Use the SELECTEDVALUE function to dynamically reference the columns based on the selected dates.

Change Flag Calculation: Calculate the change flag dynamically without hardcoding the dates.

DAX
ChangeFlag =
VAR SelectedDate1 = SELECTEDVALUE('ParameterTable'[Date1])
VAR SelectedDate2 = SELECTEDVALUE('ParameterTable'[Date2])
VAR SourceStatus = LOOKUPVALUE('InputTable'[Stage], 'InputTable'[ExtractionDate], SelectedDate1)
VAR CurrentStatus = LOOKUPVALUE('InputTable'[Stage], 'InputTable'[ExtractionDate], SelectedDate2)
RETURN
IF(
SourceStatus <> CurrentStatus,
1,
BLANK()
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

3 REPLIES 3
JamesAH
Regular Visitor

@bhanu_gautam  Thanks, but I dont think this works as I don't have stage as a column any more, the stages are contained in the columns with dates after the data is pivoted. Here is a the data, note that over time the number of columns will expand : 

JamesAH_0-1745939764500.png

 

bhanu_gautam
Super User
Super User

@JamesAH , Try using

Create a Parameter Table: Ensure you have a parameter table that allows users to select the two dates dynamically.

Dynamic Column Selection: Use the SELECTEDVALUE function to dynamically reference the columns based on the selected dates.

Change Flag Calculation: Calculate the change flag dynamically without hardcoding the dates.

DAX
ChangeFlag =
VAR SelectedDate1 = SELECTEDVALUE('ParameterTable'[Date1])
VAR SelectedDate2 = SELECTEDVALUE('ParameterTable'[Date2])
VAR SourceStatus = LOOKUPVALUE('InputTable'[Stage], 'InputTable'[ExtractionDate], SelectedDate1)
VAR CurrentStatus = LOOKUPVALUE('InputTable'[Stage], 'InputTable'[ExtractionDate], SelectedDate2)
RETURN
IF(
SourceStatus <> CurrentStatus,
1,
BLANK()
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






I just solved this! Worked out that rather than using the pivioted table to to check for change I used the original table and the lookups. So thanks @bhanu_gautam as whilst your response wasn't perfect, it gave me the idea. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.