cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dutchlimits Regular Visitor
Regular Visitor

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

Accepted Solutions
dutchlimits Regular Visitor
Regular Visitor

Re: DAX headache: Divide not working in combination with filter

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

3 REPLIES 3
Super User
Super User

Re: DAX headache: Divide not working in combination with filter

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


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!


dutchlimits Regular Visitor
Regular Visitor

Re: DAX headache: Divide not working in combination with filter

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

dutchlimits Regular Visitor
Regular Visitor

Re: DAX headache: Divide not working in combination with filter

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