cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper III
Helper III

DAX formula for percentage of time a value appears for each name

Hi All,

 

I have a data set that looks something like this:

DateNameT or F
18/11/2020AT
18/11/2020BT
19/11/2020AT
19/11/2020BF


How should I go about writing a DAX formula if I want to know the percentage of times there is T for a certain name. For example, I would like to write a measure for A which equals 100%, and a measure for B which is 50%. Any help would be appreciated. Thanks

 

 

3 REPLIES 3
Community Support
Community Support

Hi, @7ea8ea 

You can  try measure as below:

Count_T = 
VAR a =
    COUNTX ( FILTER ( 'Table', 'Table'[T or F] = "T" ), 'Table'[Date] )
RETURN
    IF ( ISBLANK ( a ), 0, a )
Count = COUNTX('Table', 'Table'[Date])
Percentage% = [Count_T]/[Count]

Check sample file for more details.

32.png

Best Regards,
Community Support Team _ Eason

Super User IV
Super User IV

@7ea8ea , Try measures for

A

calculate( divide(countx(filter(table, table[T of F] ="T"), Table[Date]), countx(Table, Table[Date])) , Table[Name] ="A")

 

or


calculate( divide(countx(filter(table, table[T of F] ="T"), Table[Date]), countx(allselected(Table), Table[Date])), Table[Name] ="A")

 

for B

calculate( divide(countx(filter(table, table[T of F] ="T"), Table[Date]), countx(Table, Table[Date])) , Table[Name] ="B")

 

or


calculate( divide(countx(filter(table, table[T of F] ="T"), Table[Date]), countx(allselected(Table), Table[Date])), Table[Name] ="B")



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Hi, thanks for the quick response. I tried using the formula you have stated but it doesn't seem to work. Maybe it's because my data has more names and dates? (I have thousands of rows). Any possible reason as to why this formula will not work for my data?

Helpful resources

Announcements
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Microsoft Ignite

Microsoft Ignite with Arun Ulag

Featured Session: Drive Data Culture with Power BI- Vision, Strategy & Roadmap. Register here https://myignite.microsoft.com #MSIgnite #PowerPlatform #Power BI ​

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors