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
Anonymous
Not applicable

How to make a measure interact with a slicer ?

I'm still relatively to DAX so pardon me if it's an obvious query.

 

Basically, I'm working with Google BigQuery's USA names dataset, that lists every birth since 1910 along with the name, gender and state of the child.

 

I downloaded the Text Filter tool from the Marketplace, so that I could write in a name that would serve as a filter for a heatmap, which would show me the prevalence of that name in each state (as in, what percentage of Texas births were named "John", etc for every state. 

 

I'm confused as to how to pass the name I'm filtering the data with to the measure (as in, I want it to be something like 

 

 

 

percentage =
 divide( 
  calculate (
    sum(nofbirths);filter(all(usanames);usanames[name]=*slicer text*));
  calculate (
    sum(nofbirths)))

 

 

 

and I'm guessing it'd only sum the births over each state instead of over the whole table since the measure would apply to each state only.

 

Do you have any idea on how I can achieve this ?

 

Update: nevermind, Zineb did the job better than the internet could. ^^

 

pourcentage = divide(CALCULATE(sum(usa_1910_current[number]);FILTER(all(usa_1910_current);usa_1910_current[name]=SELECTEDVALUE(usa_1910_current[name]) &&usa_1910_current[state]=SELECTEDVALUE(usa_1910_current[state])));CALCULATE(sum(usa_1910_current[number]);FILTER(all(usa_1910_current);usa_1910_current[state]=SELECTEDVALUE(usa_1910_current[state]))))

 

map filtered.png 

1 ACCEPTED SOLUTION
Pragati11
Super User
Super User

Hi @Anonymous ,

 

Try using the following DAX:

 

percentage = divide(
                                  calculate (
                                                  sum(nofbirths);filter(all(usanames);usanames[name]=SELECTEDVALUE(usanames[name]))

                                                 );
                                  calculate (
                                                   sum(nofbirths)

                                                 )

                               )

 

If the solution is helpful please give Kudos and if it resolves kindly mark this as a solution! 🙂

 

Thanks,

Pragati

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

1 REPLY 1
Pragati11
Super User
Super User

Hi @Anonymous ,

 

Try using the following DAX:

 

percentage = divide(
                                  calculate (
                                                  sum(nofbirths);filter(all(usanames);usanames[name]=SELECTEDVALUE(usanames[name]))

                                                 );
                                  calculate (
                                                   sum(nofbirths)

                                                 )

                               )

 

If the solution is helpful please give Kudos and if it resolves kindly mark this as a solution! 🙂

 

Thanks,

Pragati

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

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.