I am having difficulty to calculate Totals correctly in my virtual table . Here is my code. Individual rows comes correctly. I put 6 over there to make a sense.
I just need to count a column to get value of 3,960,891.
I tried HasOneFilter as well but not sure, what to write on the second half of the IF statement?
New Measure Numerator =
VAR __summarytable =
ADDCOLUMNS (
SUMMARIZE ( 'Sales Order Detail', Retailer[Retailer AB Number] ),
"@Total", CALCULATE (
SUM ( 'Sales Order Detail'[Custom Quantity] ),
'Order Type'[Order Type Transaction Group] = "Sales"
),
"@Brand Product Line Return Flag", IF ( ISBLANK ( [Return/Dump Quantity] ), "NO", "YES" )
)
VAR __total =
SUMX ( __summarytable, [@Total] )
VAR __returnstotal =
IF (
HASONEFILTER ( 'Product'[Product Marketing Brand] ),
SUMX (
FILTER ( __summarytable, [@Brand Product Line Return Flag] = "YES" ),
[@Total]
),
6
)
RETURN
__returnstotal
Hi @rit372002, we aim to consistently improve the topics being posted on the forum to help you in getting a strong solution faster. While waiting for a response, here are some tips so you can get the most out of the forum and other Enterprise DNA resources.
Use the forum search to discover if your query has been asked before by another member.
When posting a topic with formula make sure that it is correctly formatted to preformated text </>.
Use the proper category that best describes your topic
Provide as much context to a question as possible.
Include demo pbix file, images of the entire scenario you are dealing with, screenshot of the data model, details of how you want to visualize a result, and any other supporting links and details.
@AntrikshSharma,
Always good to see how others come up with solutions. I took a look at yours and have a few notes (if you dont mind )
When you FILTER over a SUMMARIZE table it results in the Storage Engine (i.e. the fast one) not being able to complete that task and has to get some help from the Formula Engine, resulting in CallbackID, which degrades performance. When we run in Dax Studio, we can see that happening.
Crossjoin doesnt suffer from that issue, but doing a cross join will bring in more data that it is needed since crossjoin produces all the possible combinations, which can bring in more data that is necessary.
Not a huge deal in a small model like this. Just wanted to share my thoughts since I’ve been really getting into performance tuning lately.
Thanks a lot @Nick_M, this is really helpful, that’s a new learning for me! I used to think that CallBackDataID only appears in cases where SE needs some help from FE with function that are not available for SE. Now I am heading over to test my code in DAX Studio!!!
Hi @rit372002, did the response provided by contributors help you solve your query? If not, how far did you get, and what kind of help you need further? If yes, kindly mark the thread as solved. Thanks!