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
ImJustConfused
Frequent Visitor

Creating a dynamic calculated column via slicer

I'm trying to create multiple slicers to filter my data. The first slicer is a date slicer. The second slicer is a count slicer. I have a categorical field, a binary field, and a date field. Similar to below. 

name | isOld  | Date
Bob  | 1      | 1/1/16
Sara | 0 | 9/15/16 Jess | 0 | 2/4/17
Bob | 1 | 7/70/17 Mike | 1 | 12/17/17
Jess | 1 | 2/28/18 Sara | 0 | 3/23/18

I have a calculated column that counts each name where the isOld field is 1. This column is set to the second slice.r I would like for the calculated column to update with the date field. In this example, if the date slicer was set to all dates after 12/31/16, the maximum for the count slicer would show 1. 

 

Currently, my code for the calculated column is:

NameCount = 
CALCULATE(
    COUNT('Table'[Name]),
    'Table'[isOld] = 1,
    ALLEXCEPT('Table','Table'[Name]))

and it does not update with the slicer. 

3 REPLIES 3
Mareias
Frequent Visitor

Hello,

 

I had the same problem today. The calculated column cant be dynamic.

 

1. Calculation column/table not support dynamic changed based on filter or slicer. (So sum(table[column]) will return fixed value)
2. Measure can be affected by filter/slicer, so you can use it to get dynamic summary result.

 

Try using a calculated measure and see if that suits you.

@Mareias Thank you for the suggestion. 

 

I've tried using a calculated Measure, but I am unable to use that Measure in a slicer. Is there a different way that would help me achieve the same result?

Hi @ImJustConfused,

 

You should manually create an extra table which is unrelated to fact data table to list all available count numbers for users to choose from.

1.PNG

 

Create measures like below:

NameCount = 
CALCULATE(
    COUNT('Test Table'[name]),
    'Test Table'[isOld] = 1,ALLSELECTED('Test Table'[Date]))+0

selected CountNo = SELECTEDVALUE(slicertable[CountNo])

check_ = IF([NameCount]=[selected CountNo],1,0)

Add measure [check_] to visual level filter and set its value to 1.

1.PNG2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.