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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
anushkavp27
Frequent Visitor

Save filter and use to calculate measure

I have a power BI dashboard with a bunch of filters. I was wondering if there is a way to save the values of a filter and then use it in another calculated measure. 

For example, I have the following filter on my dashboard:

anushkavp27_0-1711380463876.png

And say, the user has filtered for the 3 months as shown above - 2024M03, 2024M04, 2024M05

 

And then I am hoping to use the saved filter in the below measure here:

GreaterTotals =
VAR a =
    SUMMARIZE (
        ALLSELECTED ( fiscal_calendar ),
        [fiscal_month],
        [fiscal_quarter]
    )
VAR b =
    ADDCOLUMNS (
        CROSSJOIN ( ALLSELECTED ( 'Part table'[part_nbr]), a ),
        "Groupby",
            [part_nbr] & " " & [fiscal_quarter],
        "Greats", [Greater?]
    )
VAR c =
    SELECTEDVALUE ( 'Part Table'[part_nbr] ) & " "
        & SELECTEDVALUE ( fiscal_calendar[fiscal_quarter] )
RETURN
    SUMX (
        FILTER ( b, [part_nbr] IN VALUES ( 'Part Table'[part_nbr] ) && [Groupby] = c ),
        [Greats]
    )

Hoping to replace the group-by from the fiscal_quarter to the above calculated measure (that is the saved filter that the user selects) rather than the fiscal quarter mentioned. So, it should be something like:

VAR b =
    ADDCOLUMNS (
        CROSSJOIN ( ALLSELECTED ( 'Part table'[part_nbr]), a ),
        "Groupby",
            [part_nbr] & " " & [user_selected_filter_month],
        "Greats", [Greater?]
    )

 

Please let me know if saving a filter this way is possible.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @anushkavp27 ,

@amitchandak  is Right , so i want to give other solution:

Power BI does not directly allow for "saving" filter selections in a way that they can be directly referenced within DAX formulas as variables.

You're already on the right track with using in your measure. To dynamically use the user-selected months in your calculations, ensure that your slicer or filter is correctly set up to allow users to select the months.

VAR b = 
    ADDCOLUMNS (
        CROSSJOIN ( ALLSELECTED ( 'Part table'[part_nbr] ), a ),
        "Groupby",
            [part_nbr] & " " & SELECTEDVALUE(fiscal_calendar[fiscal_month]),
        "Greats", [Greater?]
    )

Best Regards,

Xianda Tang

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

3 REPLIES 3
Anonymous
Not applicable

Hi @anushkavp27 ,

@amitchandak  is Right , so i want to give other solution:

Power BI does not directly allow for "saving" filter selections in a way that they can be directly referenced within DAX formulas as variables.

You're already on the right track with using in your measure. To dynamically use the user-selected months in your calculations, ensure that your slicer or filter is correctly set up to allow users to select the months.

VAR b = 
    ADDCOLUMNS (
        CROSSJOIN ( ALLSELECTED ( 'Part table'[part_nbr] ), a ),
        "Groupby",
            [part_nbr] & " " & SELECTEDVALUE(fiscal_calendar[fiscal_month]),
        "Greats", [Greater?]
    )

Best Regards,

Xianda Tang

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

okay, this helped. Thank you for pointing me in the right direction. I was able to use the SELECTEDVALUE() function and modify my DAX to get my use case working.
amitchandak
Super User
Super User

@anushkavp27 , No, Slicer values can only be used by a measure

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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