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

Dynamically Update DAX with Slicer

Hi all,

I find this forum a valuable resource and am hoping someone can assist me with the below problem.

I have a sample set of personal records, with some data and some n/a.

 

NameBirthdayNationalityGenderAgeOccupationAddress
Steve22/04/1990BritishMale31BuilderScotland
Alicen/aIrishFemalen/an/aIreland
Bobn/aBritishn/a52Teachern/a



My goal is to show how complete these records are (as in, not showing n/a) in the form of a percentage. I have managed to achieve this with 2 columns. The first one counts the number of n/a and returns a percentage:


Count n/a Percentage =
DIVIDE (
COUNTX ( FILTER ( 'Table', 'Table'[Birthday] = "n/a" ), [Birthday] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Nationality] = "n/a" ), [Nationality] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Gender] = "n/a" ), [Gender] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Age] = "n/a" ), [Age] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Occupation] = "n/a" ), [Occupation] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Address] = "n/a" ), [Address] ),
COUNTROWS ( 'Table' ) * 7
)

The second column calculates the reverse of this to show percentage complete

Percentage Complete = DIVIDE(100 - ('Table'[Count n/a Percentage]*100),100)

 

This works fine as seen below:

ZW_0-1643044213340.png

 

However, if I use Name as a slicer this percentage doesn’t change to show only the percentage complete in that row.

ZW_4-1643044414198.png

 

 

My ideal output would be this:

ZW_2-1643044295560.pngZW_1-1643044287576.png

ZW_3-1643044305620.png

Any help would be greatly appreciated.

Thank you

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ZW , I think this correct as measure.

Count n/a Percentage =
DIVIDE (
COUNTX ( FILTER ( 'Table', 'Table'[Birthday] = "n/a" ), [Birthday] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Nationality] = "n/a" ), [Nationality] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Gender] = "n/a" ), [Gender] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Age] = "n/a" ), [Age] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Occupation] = "n/a" ), [Occupation] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Address] = "n/a" ), [Address] ),
COUNTROWS ( 'Table' ) * 7
)

 

Not as column , as first row do not have any N/a and it 71 %

 

 

you can have column like

 

Count n/a Percentage =
DIVIDE (
if('Table'[Birthday] = "n/a" ,1,0 )
+if('Table'[Nationality] = "n/a" ,1,0 )
+if('Table'[Gender] = "n/a" ,1,0 )
+if('Table'[Age] = "n/a" ,1,0 )
+if('Table'[Occupation] = "n/a" ,1,0 )
+if('Table'[Address] = "n/a" ,1,0 ) ,
7
)

 

 

But my advice is use first one as a measure

View solution in original post

2 REPLIES 2
ZW
Frequent Visitor

Thank you, I didn't realise columns and measures behaved differently when it came to splicing. 

The new measure works perfectly!

amitchandak
Super User
Super User

@ZW , I think this correct as measure.

Count n/a Percentage =
DIVIDE (
COUNTX ( FILTER ( 'Table', 'Table'[Birthday] = "n/a" ), [Birthday] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Nationality] = "n/a" ), [Nationality] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Gender] = "n/a" ), [Gender] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Age] = "n/a" ), [Age] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Occupation] = "n/a" ), [Occupation] )
+ COUNTX ( FILTER ( 'Table', 'Table'[Address] = "n/a" ), [Address] ),
COUNTROWS ( 'Table' ) * 7
)

 

Not as column , as first row do not have any N/a and it 71 %

 

 

you can have column like

 

Count n/a Percentage =
DIVIDE (
if('Table'[Birthday] = "n/a" ,1,0 )
+if('Table'[Nationality] = "n/a" ,1,0 )
+if('Table'[Gender] = "n/a" ,1,0 )
+if('Table'[Age] = "n/a" ,1,0 )
+if('Table'[Occupation] = "n/a" ,1,0 )
+if('Table'[Address] = "n/a" ,1,0 ) ,
7
)

 

 

But my advice is use first one as a measure

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.