Forum Discussion
Measure DAX division not working as expected - skipping rows
- 1 year ago
Thank you, I had to adapt the DAX a bit but I was able to fix it by using SUMX for my value as follows:
% Sales on X =var _category = SELECTEDVALUE('Table'[SKU Category])var _value = SUMX('Table', 'Table'[Total Price])var _total = [Total X Sales]var _result = IF(_category <> "X", DIVIDE(_value, _total, ""), BLANK())return _resultMy "Total Price" column in my data set is alreayd the Qty * Unit Price.My total variable, [Total X Sales] was already being calculated correctly.
Hi TessSA
For each row in your table, this variable should return a non-blank value: var _value = SELECTEDVALUE('Table'[Total Price]). If it returns blank, it could be because _total for those rows return blank. To troubleshoot, return the result of each variable one by one either in the same or separate measures.
Thanks for your guidance. After looking into, it does seem that at the individual row level the measure is calculating correctly but the issues arises for the SKU Category Row Totals when there are multiple rows assigned to one same SKU category, it returns a blank value. I think the issue comes from the fact that the selectedvalue function expects a unique value for the column selected, while in the total I have many of them (under a selected SKU Category there can exist various lines). Maybe I should adapt my measure and use X functions (like sumx) to iterate over each individual row and get the final result needed. I am not sure how to add a X function in my measure, do you have any tips or other ways to solve this issue?