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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Paulyeo11
Impactful Individual
Impactful Individual

How to make my expression dynamic by passing variable thru Slicer ?

Hi All

 
Below 2 expression working fine  , But they are not dynamic they are static , it there a way to make the expression i can pass variable from Slicer ? So that i only need one table instead of many table :-
 
_Growth BRAND =
VAR competitor = SELECTEDVALUE ( 'SALES'[BRAND_C])
VAR currentYear = SELECTEDVALUE ( 'Date'[Year] )
VAR currentAMT = SUM ( 'SALES'[sales])
VAR previousAMT = SUMX ( FILTER ( ALLSELECTED( 'SALES' ), 'SALES'[BRAND_C] = competitor && RELATED ( 'Date'[Year] ) = currentYear - 1 ), 'SALES'[sales])
RETURN
DIVIDE ( currentAMT - previousAMT, previousAMT )
 
 
_Growth GROUP =
VAR competitor = SELECTEDVALUE ( 'SALES'[GROUP_CLASS])
VAR currentYear = SELECTEDVALUE ( 'Date'[Year] )
VAR currentAMT = SUM ( 'SALES'[sales])
VAR previousAMT = SUMX ( FILTER ( ALLSELECTED( 'SALES' ), 'SALES'[GROUP_CLASS] = competitor && RELATED ( 'Date'[Year] ) = currentYear - 1 ), 'SALES'[sales])
RETURN
DIVIDE ( currentAMT - previousAMT, previousAMT )
 
Above link is my PBI file
 
Paul Yeo
 
1 ACCEPTED SOLUTION
5 REPLIES 5
amitchandak
Super User
Super User

@Paulyeo11 , if you slicer from the table or table joined to it you do need to use selected value. Also what do you  mean by not dynamic ?

use in 'SALES'[GROUP_CLASS] in  values( 'SALES'[GROUP_CLASS]) for all values. Selectedvalue will give only one value.

Hi Amit

Thank you for your fast reply. 

Dynamic = Only using one Table and user can select to view report Brand or SBU by click the Slicer. 

Paul

@Paulyeo11 , Not clear. Can you explain

Hi Amit

 

Below link is my PBI file :-

https://www.dropbox.com/s/78masspm617220k/PBT_SAMPLE%20100%20ROW%20JAN%202021%20V005.pbix?dl=0

Now i need to have 2 Table , i want to reduce to 1 Table . 

I am thinking using Slicer , since BRNAD_C and GROUP_CLASS they are fields , i cannot put in Slicer. not sure how to use personlise mode , allow user change field.

Paulyeo11_0-1610083450448.png

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.