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
chq
Helper II
Helper II

Apply filter to formula

Is there a way to add a formula filter for a certain year to the following equation? I have tried multiple ways but end up with errors. 

# Count = SUMX( VALUES( 'Table'[Event Title] )  ,CALCULATE(DISTINCTCOUNT( 'Table'[ID#] ) ))

 

1 ACCEPTED SOLUTION
Iamnvt
Continued Contributor
Continued Contributor

5 REPLIES 5
Cmcmahan
Resident Rockstar
Resident Rockstar

So this measure reads seems like you're trying to sum the count of distinct table IDs, but only while using the [Event Title] column?? It's like you're asking "How many tables do we have? Sum all those numbers you just told me! Oh, and the only data I'm giving you to work with is the list of Event Titles!" That seems not right to me.  

 

I would start from scratch and re-write it like this for 2019:

# Count = CALCULATE( DISTINCTCOUNT('Table'[ID#]), FILTER('Table', YEAR('Table'[Date]) = 2019) )

Depending on what sort of visual you're putting this in, you may not have to specify all this.  If it's in a column chart with the year as an axis, PowerBI will automatically do this filtering for you if you set up the value of the bar to be a distinct count of IDs. More info on how you're using this and/or table structure would be helpful if this isn't the result you're looking for.

 

Maybe this will help explain what the desired outcome is



Date      Event Title     # Distinct Count          Week

1/1/19         A                  50                              1

1/3/18         B                  75                              1

7/4/19         X                  99                              4

7/4/18         V                  10                              4

TOTAL                              234

My formula is giving me the # Distinct count correctly, So the above table is fine and already in my report. Below that Table I want to place the following:

Week      Distinct Count 2018          Distinct Count 2019       Difference               %Change
1                         75                                      50                             -25                         -33.33%

4                         10                                      99                              89                           890%


Does that help?

tex628
Community Champion
Community Champion

What do you get if you just apply this:

Measure =
Calculate(
Distinctcount(Table1[ID]),
Calendar[Year] = "2019"
)

From my perspective you shouldnt need anything else with the data provided..


Connect on LinkedIn
Iamnvt
Continued Contributor
Continued Contributor

This works beautifully thank you so much for your help!

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.