Forum Discussion
Calculate function using Containsstring filter not working as expected
- 4 years ago
Hi Anonymous ,
Maybe you could try this Measure.
ACT% = DIVIDE ( CALCULATE ( SUM ( vw_shrinkage_act[Total_Hrs] ), FILTER ( vw_shrinkage_act, vw_shrinkage_act[Shrinkage_cat_code] <> "SHIFT" ) ), CALCULATE ( SUM ( vw_shrinkage_act[Total_Hrs] ), CONTAINSSTRING ( vw_shrinkage_act[Shrinkage_cat_code], "SHIFT" ) ) )Then the result will look like this:
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
Hi:
Instead of using ContainsString can you consider trying a measure like:
Share =
= DIVIDE(SUMX(
vw_shrinkage_act[Total_Hrs]
),
SUMX(ALLSELECTED(
vw_shrinkage_act), [Total Hours]))
That doesn't quite work for what I'm trying to do. Example table below
| Category | Value |
| Absence | 12 |
| Leave | 4 |
| Break | 3 |
| Shift | 82 |
Absence / Shift = 0.146 or 14.6%
Leave / Shift = 0.048 or 4.8%
Break / Shift = 0.036 or 3.6%
All / Shift = 0.231 or 23.1%
The problem I run into is that Shift / Shift = 100% and it gets added to the total values which just makes everything wrong. "Shift" is only there to be the denominator in the division, I need it excluded from the numerator which is where I got to the two measures I originally posted.
- Whitewater1004 years agoSolution Sage
Hi:
I understand. Can you try this link for report? There is a table with calculation as well, but most are measures. I hope this helps!
https://drive.google.com/file/d/1O81vtC1QOyE_hoiLrBttXw-6Ibr9X1uE/view?usp=sharing
- Anonymous4 years agoNot applicable
Hey thanks for writing up these examples. We are super close here. The only issue left is that "Tot Shift" being MAX(value) isn't usable. My source table has many thousands of rows, there are many values for "Shift" being Summed and aggregated, so dividing by the maximum value of Shift yields incorrect math. I tried making some changes but I guess I can't use SELECTEDVALUE on a calculated measure.
- Whitewater1004 years agoSolution Sage
Hi:
No problem. They are based on what you shared. You can have a variable in a calculated measure.
Measure Name
var shift = Table[Shift[ID]
return
the DAX referring to this variable. Example only.
return
Do you have example data(Model-table-visual you want to create) that reflects all the nuances to writing the DAX?