Forum Discussion
Filter data using slicer
Hello Everyone,
I have this tableau calculation where [Include in MPR Para] is a Tableau parameter and INCLUDE_IN_MPR is a column.
if [Include in MPR Para] = 'Included in MBO' and ([INCLUDE_IN_MPR]) = TRUE then TRUE
elseif [Include in MPR Para] = 'Excluded from MBO' and ([INCLUDE_IN_MPR]) in (FALSE/*,Null*/) then TRUE
elseif [Include in MPR Para] = 'All' and ([INCLUDE_IN_MPR]) in (True, False, Null) then TRUE
else FALSE end
I would like to replicate this in power bi.
I have created a disconnected table in Power BI with two values, 'Included in MBO' and 'All'. I tried to replicate the calculation with the below dax but it is not working.
Calc_Dax =
Thanks, just adding Include_in_mpr to the rows in the matrix visual solved it.
9 Replies
- mh2587Super User
_Flag = --try this might help you VAR sel = SELECTEDVALUE('Show Categories'[Value]) RETURN SWITCH( TRUE(), sel = "Included in MBO" && SELECTEDVALUE(APEX_INTL_MSF_FACT[INCLUDE_IN_MPR]) = TRUE(), 1, sel = "Excluded from MBO" && (SELECTEDVALUE(APEX_INTL_MSF_FACT[INCLUDE_IN_MPR]) = FALSE() || ISBLANK(SELECTEDVALUE(APEX_INTL_MSF_FACT[INCLUDE_IN_MPR]))), 1, sel = "All", 1, 0 ) - danextianSuper User
Is INCLUDE_IN_MPR a logical (TRUE/FALSE) column or a text column containing the word "TRUE"? If it is a logical type, the values should appear italicized in Data view, and the comparison should use TRUE() rather than "TRUE".
Also, the result of MAX(APEX_INTL_MSF_FACT[INCLUDE_IN_MPR]) can change depending on where the measure is being evaluated. In a visual, each row can have its own filters (for example a specific customer, product, or month), and the measure is calculated only using the data visible for that row.
- wardy912Super User
Hi kunjan_ashara
Try this:Calc_Dax = VAR Sel = SELECTEDVALUE ( 'Show Categories'[Value], "All" ) VAR IncludeFlag = MAX ( APEX_INTL_MSF_FACT[INCLUDE_IN_MPR] ) RETURN SWITCH ( TRUE(), -- Included in MBO Sel = "Included in MBO" && IncludeFlag = TRUE(), 1, -- Excluded from MBO Sel = "Excluded from MBO" && ( IncludeFlag = FALSE() || ISBLANK ( IncludeFlag ) ), 1, -- All Sel = "All", 1, 0 )
Once you've added the measure to a slicer, change the visual level filter to 'is 1' in the right hand filter pane as shown in the screenshot--------------------------------
I hope this helps, please give kudos and mark as solved if it does!
Connect with me on LinkedIn.
Subscribe to my YouTube channel for Fabric/Power Platform related content!
- jgeddesSuper User
The following replicates your tableau calculation.
Calc_DAX = var _paraValue = SELECTEDVALUE('Show Categories'[Value]) var _tableValue = SELECTEDVALUE(apex_intl_msf_fact[Include_in_mpr]) var _result = SWITCH( TRUE(), _paraValue = "Included in MBO" && _tableValue = TRUE(), TRUE(), _paraValue = "Excluded from MBO" && _tableValue IN {FALSE()}, TRUE(), _paraValue = "All" && (_tableValue IN {TRUE(), FALSE()} || ISBLANK(_tableValue)), TRUE(), FALSE() ) RETURN _result - cengizhanarslanSuper User
Please try the measure below:
Calc_Dax = VAR _Sel = SELECTEDVALUE ( 'Show Categories'[Value] ) VAR _IncludeFlag = MAX ( APEX_INTL_MSF_FACT[INCLUDE_IN_MPR] ) RETURN SWITCH ( TRUE (), _Sel = "Included in MBO" && _IncludeFlag = TRUE (), 1, _Sel = "Excluded from MBO" && _IncludeFlag <> TRUE (), 1, _Sel = "All", 1, 0 )Then apply this measure as a visual-level filter set to is 1 on your visuals.
- v-echaithraCommunity Support
Hi kunjan_ashara ,
Thank you cengizhanarslan , jgeddes , wardy912 , danextian for your inputs.
We’d like to follow up regarding the recent concern. Kindly confirm whether the issue has been resolved, or if further assistance is still required. We are available to support you and are committed to helping you reach a resolution.
Thank you. - kunjan_asharaNew Member
Thanks, just adding Include_in_mpr to the rows in the matrix visual solved it.
- kunjan_asharaNew Member
Thanks, just adding Include_in_mpr to the rows in the matrix visual solved it.
- v-echaithraCommunity Support
Hi kunjan_ashara ,
Thanks for letting us know that the issue is resolved, glad to hear the latency has been addressed. Please feel free to reach out if you need any further assistance.