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
dutchlimits
Helper I
Helper I

DAX headache: Divide not working in combination with filter

 

Hi dear community. 

 

I've been trying for hours, but I cannot seem to get the right results. I've had different results but my last attempt is in the screenshot. 

 

What i need to do is calculate a percentage based on hours. 

SICK HOURS / TOTAL HOURS * 100

 

The expected results are in the notepad below. 

 

I cannot attach the report because of privacy unfortunately. 

 

Column Tijdsregistraties["Dagen"] is a custom column with the following: Dagen = Tijdsregistraties[duur] / 60 / 60 / 1000 / 8

 

The sick hours is based on a column ProductRegistratie which contains the text "Ziek" it uses the same Dagen column but with this filter on it.

 

My attempt is: 

DagenZiektePercentagee =
var ziektedagen = CALCULATE(SUM(Tijdsregistraties[Dagen]);Tijdsregistraties[ProductRegistratie] = "Ziek")
var dagentotaal = SUM(Tijdsregistraties[Dagen])

return
ziektedagen / dagentotaal

 

 

Capture.JPG

1 ACCEPTED SOLUTION

Well maybe im stupid or need to learn more about PowerBI. 

 

Using a column with this DAX command was giving strange results.

 

After using a measure, it works perfectly... 

 

Why does this matter so much...? 

 

Anyway : this worked as a charm in a measure:

Dagentest = SUM(Tijdsregistraties[Dagen Ziek]) / SUM(Tijdsregistraties[Dagen Gewerkt]) * 100

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

Can you just click the little drop down arrow in the Fields area for your column and click Show as | Percent of Total?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi

 

Thanks for the suggestion, i tried that and that does not give me the expected results. The results should be seperately calculated from eachother per individual exactly like i showed in the notepad. 

 

I need to calculate per individual:

DIVIDE: SICK DAYS BY TOTAL WORK DAYS TIMES 100

Well maybe im stupid or need to learn more about PowerBI. 

 

Using a column with this DAX command was giving strange results.

 

After using a measure, it works perfectly... 

 

Why does this matter so much...? 

 

Anyway : this worked as a charm in a measure:

Dagentest = SUM(Tijdsregistraties[Dagen Ziek]) / SUM(Tijdsregistraties[Dagen Gewerkt]) * 100

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.

Top Solution Authors