Forum Discussion

menphis21's avatar
menphis21
Icon for Helper IV rankHelper IV
1 year ago
Solved

Using a parametrer in dax for all the app?

HI
i have an app that i need to update all quarter.

 I want to create a parameter, for example Actual_Quarter = "Q1", and then use this parameter inside a DAX measure.

For instance, I want to create a measure like:

Market Cap = CALCULATE( SUM('DB'[value]), FILTER('DB', 'DB'[variable] = "Market Capitalization"), -- Filter using the parameter here )

How can I define such a parameter and use it effectively in the CALCULATE() function?

Thanks

  • menphis21's avatar
    menphis21
    1 year ago

    Hello,
    Thank you.
    I found another solution.
    you can create a parameter in Power Query ( Manage Parameters - New Parameter) and for example create Year = 2025
    you need to right click on this parameter and enable Load enable.

    and as you will be able to change your parameter, it will be updated after a refresh.

     

    Thanks

3 Replies

  • v-karpurapud's avatar
    v-karpurapud
    Icon for Community Support rankCommunity Support

    Hello menphis21 


    Welcome to the Microsoft Fabric Forum,
     

    Regarding the measure to dynamically filter your data by quarter using a parameter in DAX,

     

    1. Create a disconnected parameter table to allow flexible quarter selection:

       

        DAX:
        

    QuarterParameter = DATATABLE(
        "Quarter", STRING,
        {{"Q1"}, {"Q2"}, {"Q3"}, {"Q4"}}
    )
    

     

    2. Add a slicer to your report using the QuarterParameter[Quarter] column. This enables users to select the active quarter dynamically.

     

    3. Define a new measure that captures the user's selection and includes a default value to avoid errors:
        
       DAX:
       

    SelectedQuarter = SELECTEDVALUE(QuarterParameter[Quarter], "Q1")

     

    4. Create Market Cap measure to incorporate the selected quarter as a filter:
      
        DAX: 
       

    Market Cap =
    VAR Selected = [SelectedQuarter]
    RETURN
    CALCULATE(
        SUM('DB'[value]),
        'DB'[variable] = "Market Capitalization",
        'DB'[Quarter] = Selected
    )
    


    5. Make sure that the 'DB'[Quarter] column has values in the same format as your parameter table (e.g., "Q1", "Q2"). If necessary, you can format or extract the quarter from a date column using Power Query or DAX

     


    If this information helps resolve your issue, kindly consider marking this response as the Accepted Solution, as it may assist other community members facing similar challenges.

     

    Thank you for being part of the Microsoft Fabric Community.



     

    • menphis21's avatar
      menphis21
      Icon for Helper IV rankHelper IV

      Hello,
      Thank you.
      I found another solution.
      you can create a parameter in Power Query ( Manage Parameters - New Parameter) and for example create Year = 2025
      you need to right click on this parameter and enable Load enable.

      and as you will be able to change your parameter, it will be updated after a refresh.

       

      Thanks

  • v-karpurapud's avatar
    v-karpurapud
    Icon for Community Support rankCommunity Support

    Hi menphis21 

    May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

    Thank you.