Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Parameter in summarize

Value which is in the Threshold variable is not getting passed. Kindly help me on this...
 
Filtered_Customs_Data_Input =
VAR Threshold = [Parameter Value]--500  -- Replace with your parameter or use a disconnected table parameter
VAR FilteredIdentifiers =
    SUMMARIZE(
        FILTER(
            ADDCOLUMNS(
                SUMMARIZE('CBAM_Goods_InScope', [EntryIdentifier]),
                "TotalCustomsValue", CALCULATE(SUM('CBAM_Goods_InScope'[CustomsValue]))
            ),
            [TotalCustomsValue] > Threshold
        ),
        [EntryIdentifier]
    )
RETURN
    FILTER(
        'CBAM_Goods_InScope',
        'CBAM_Goods_InScope'[EntryIdentifier] IN SELECTCOLUMNS(FilteredIdentifiers, "EntryIdentifier", [EntryIdentifier])
    )
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Anonymous ,
    Thank you for reaching out to us on Microsoft Fabric Community Forum. Also  thanks Nasif_Azam and rajendraongole1 for the helpful insights!

    I tried to recreate it on my local upon my understanding.Please refer the screenshot and file for your reference.


    If this answer meets your requirement,give us kudos and consider accepting it as solution.If still require further assistance, feel free to reachout!

    Regards,
    Pallavi G.

21 Replies

  • Hi Anonymous  - create a measure for selected value as below:

     

    SelectedThreshold = SELECTEDVALUE(ThresholdParameter[Value], 500)

     

    Now , create a measure now:

    Filtered_Customs_Data_Input =
    VAR Threshold = [SelectedThreshold] -- this should be a scalar measure
    VAR FilteredIdentifiers =
    SUMMARIZE(
    FILTER(
    ADDCOLUMNS(
    SUMMARIZE('CBAM_Goods_InScope', [EntryIdentifier]),
    "TotalCustomsValue", CALCULATE(SUM('CBAM_Goods_InScope'[CustomsValue]))
    ),
    [TotalCustomsValue] > Threshold
    ),
    [EntryIdentifier]
    )
    RETURN
    FILTER(
    'CBAM_Goods_InScope',
    'CBAM_Goods_InScope'[EntryIdentifier] IN SELECTCOLUMNS(FilteredIdentifiers, "EntryIdentifier", [EntryIdentifier])
    )

     

    Hope this helps.

    • Anonymous's avatar
      Anonymous
      Not applicable

      rajendraongole1 Thanks I have already tried that but it is not working 

       

      Filtered_Customs_Data_Input =
      VAR Threshold = [Parameter Value]

      /*SELECTEDVALUE('Parameter'[Parameter], 500)--[Parameter Value]--500  -- Replace with your parameter or use a disconnected table parameter*/
      VAR FilteredIdentifiers =
          SUMMARIZE(
              FILTER(
                  ADDCOLUMNS(
                      SUMMARIZE('CBAM_Goods_InScope', [EntryIdentifier]),
                      "TotalCustomsValue", CALCULATE(SUM('CBAM_Goods_InScope'[CustomsValue]))
                  ),
                  [TotalCustomsValue] > Threshold
              ),
              [EntryIdentifier]
          )
      RETURN
          FILTER(
              'CBAM_Goods_InScope',
              'CBAM_Goods_InScope'[EntryIdentifier] IN SELECTCOLUMNS(FilteredIdentifiers, "EntryIdentifier", [EntryIdentifier])
          )
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,
    Thank you for reaching out to us on Microsoft Fabric Community Forum. Also  thanks Nasif_Azam and rajendraongole1 for the helpful insights!

    I tried to recreate it on my local upon my understanding.Please refer the screenshot and file for your reference.


    If this answer meets your requirement,give us kudos and consider accepting it as solution.If still require further assistance, feel free to reachout!

    Regards,
    Pallavi G.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous Thanks a lot for your time and help. Based on the value that you have selected in the Threshold I wanted to filter the records in the Filtered_Customs_Data_Input table so that I dont need to use the visual filter at all. Is that feasible?

       

      Basically based the below filter condition, only those records which matches the given condition only should be fetched in Filtered_Customs_Data_Input table

       


      VAR FilteredIdentifiers =
          FILTER(CustomsWithTotal, [TotalCustomsValue] > Threshold)
       
       If you hardcode this value it works in similar way it should work based on the parameter.
       
      VAR FilteredIdentifiers =
          FILTER(CustomsWithTotal, [TotalCustomsValue] > Threshold) -- This is not working
       
      VAR FilteredIdentifiers =
          FILTER(CustomsWithTotal, [TotalCustomsValue] > 150) -- This is working
      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,
        Thank you again for the follow-up. I would be happy to assist you!

        Hardcoding a value like > 150 works because calculated tables are created at model load. But when using a dynamic value from a slicer (like Threshold), the table does not update. That is expected because calculated tables are not dynamic in the same way visuals or measures are, since calculated tables do not respond to slicers , only DAX measures do. For dynamic behavior, measures with visual-level filters are the way to go.

        To get dynamic filtering based on a slicer, the best approach is to use the original CBAM_Goods_InScope table in your visuals. Then, create a measure like ShowRow that checks if each entry meets the selected threshold. Finally, apply a visual-level filter where ShowRow = 1, this gives you the same result you wanted from the calculated table, but in a way that responds to slicer changes.

        I hope this helps.

        Thank you.

  • Hey Anonymous ,

    The issue you're encountering is "Value which is in the Threshold variable is not getting passed". The value in the Threshold variable is not getting passed properly in your SUMMARIZE logic is often due to context transition or the way Threshold is referenced within the nested row context of FILTER and ADDCOLUMNS.

    Root Cause

    The variable Threshold is a scalar defined outside of the FILTER expression, but inside the ADDCOLUMNS, you're operating within a row context introduced by SUMMARIZE, which does not automatically convert into a filter context. As a result, DAX may not correctly evaluate Threshold for each row especially when used in CALCULATE inside ADDCOLUMNS.

     

    Use VAR and restructure your code like this:

    Filtered_Customs_Data_Input =
    VAR Threshold = [Parameter Value] -- e.g., 500
    VAR CustomsWithTotal =
        ADDCOLUMNS(
            SUMMARIZE('CBAM_Goods_InScope', [EntryIdentifier]),
            "TotalCustomsValue", CALCULATE(SUM('CBAM_Goods_InScope'[CustomsValue]))
        )
    VAR FilteredIdentifiers =
        FILTER(
            CustomsWithTotal,
            [TotalCustomsValue] > Threshold
        )
    RETURN
        FILTER(
            'CBAM_Goods_InScope',
            'CBAM_Goods_InScope'[EntryIdentifier] IN
                SELECTCOLUMNS(FilteredIdentifiers, "EntryIdentifier", [EntryIdentifier])
        )

     

    Alternative: Use a Measure Instead of Variable

    If [Parameter Value] is dynamic (like a disconnected slicer table), consider creating a measure and referencing it instead:

    Threshold Measure = SELECTEDVALUE('Parameter Table'[Value])

    And then:

    VAR Threshold = [Threshold Measure]

     

    Things to remember

    • Always compute columns before filtering when dealing with nested contexts.

    • Use SELECTCOLUMNS or VALUES to extract clean lists for use in IN clauses.

    • Ensure Threshold is a scalar value — not a table or column.

     

    If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.


    Best Regards,
    Nasif Azam

    • Anonymous's avatar
      Anonymous
      Not applicable

      this is not working as well...

      • Nasif_Azam's avatar
        Nasif_Azam
        Super User

        Thanks for the update. If the revised approach didn’t solve the issue, let’s take a deeper look at possible reasons and other workarounds:

        Potential Issues

        1. [Parameter Value] might not be evaluated as expected

          • If [Parameter Value] is coming from a slicer or a disconnected table, it must be a scalar. Use SELECTEDVALUE() to ensure it returns a single value:

            VAR Threshold = SELECTEDVALUE('Parameter Table'[Value], 500)  // fallback to 500
        2. Threshold might be blank

          • If no value is selected in the parameter slicer, [Parameter Value] may return blank, causing all rows to be filtered out. You can guard against this with:

            VAR Threshold = IF(ISBLANK(SELECTEDVALUE('Parameter Table'[Value])), 0, SELECTEDVALUE('Parameter Table'[Value]))
        3. Data Type Mismatch

          • Double-check if CustomsValue and the parameter are both numeric. If one is text and the other is numeric, the comparison may silently fail.

        Try this full version with explicit fallback and clean context flow:

        Filtered_Customs_Data_Input =
        VAR Threshold = SELECTEDVALUE('Parameter Table'[Value], 0)  // default to 0 if nothing selected
        
        VAR CustomsWithTotal =
            ADDCOLUMNS(
                SUMMARIZE('CBAM_Goods_InScope', [EntryIdentifier]),
                "TotalCustomsValue", CALCULATE(SUM('CBAM_Goods_InScope'[CustomsValue]))
            )
        
        VAR FilteredIdentifiers =
            FILTER(
                CustomsWithTotal,
                [TotalCustomsValue] > Threshold
            )
        
        RETURN
            FILTER(
                'CBAM_Goods_InScope',
                'CBAM_Goods_InScope'[EntryIdentifier] IN
                    SELECTCOLUMNS(FilteredIdentifiers, "EntryIdentifier", [EntryIdentifier])
            )

         

        Debug Tip

        Temporarily add a measure like this to check what your parameter is returning:

        Measure_CheckThreshold = SELECTEDVALUE('Parameter Table'[Value])

        Add it to a card visual to verify it’s not blank or unexpected.

         

        If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.


        Best Regards,
        Nasif Azam

  • Anonymous's avatar
    Anonymous
    Not applicable

    May be I cannot use Parameter/Variable with Summarize? If yes, then how can i achieve this? Basically I want to filter out the records that are in scope for calculation.