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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
harshagraj
Post Partisan
Post Partisan

Slicer value in calculated column

Hello all how do i assign a dynamic slicer value on a calculated column. Please see the attached.

harshagraj_0-1658300126916.png

I cant create a measure for this. Kinldy help. I just need to display 1 for the selected value from slicer.

 

1 ACCEPTED SOLUTION
Avantika-Thakur
Solution Supplier
Solution Supplier

Hi @harshagraj ,

As you are using a calculated column, we cannot use the selected value from segment code slicer in the DAX for calculated column as calculated columns work on row by row calculation and tend to give static values in each row of the table.
You might need to create a measure for dynamic filtering of the segment code in the DAX.

 

Thanks!

Avantika

View solution in original post

3 REPLIES 3
Avantika-Thakur
Solution Supplier
Solution Supplier

Hi @harshagraj ,

There is one way that we can handle this.

1) Create a separate lookup for the segment codes that you will be using in the Slicer.

Ex: I have used alphabets A-D as examples for segment codes

AvantikaThakur_6-1658302157510.png

 

2) And you will have a separate column for segment codes in Fact table as below

AvantikaThakur_3-1658302021536.png

 

3) Create a relationship between these two tables as below on the segment codes columns in respective tables

AvantikaThakur_5-1658302059346.png

 

4) And then you can create a measure like :

Measure  = IF(SELECTEDVALUE('Fact'[Segment code])=SELECTEDVALUE('Lookup'[Segment code]),1,0)
 
Hope this helps.
Please accept the solution if it answers your query.
Thanks!
Avantika

 

Avantika-Thakur
Solution Supplier
Solution Supplier

Hi @harshagraj ,

As you are using a calculated column, we cannot use the selected value from segment code slicer in the DAX for calculated column as calculated columns work on row by row calculation and tend to give static values in each row of the table.
You might need to create a measure for dynamic filtering of the segment code in the DAX.

 

Thanks!

Avantika

Hi @Avantika-Thakur thanks for the reply but the problem is cant able to create a measure for this too.I cant aggregate Segment code column.

IF(_??__(SegmentCode) =Selectedvalue(Segmentcode),1,0)

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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