Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

DAX Sum function with Where condition

Hi,

 

I need help in creating the DAX formula, one created is not working correctly

 

this is SQL query 

SELECT
CreatedMonth,
Product,
SUM(Value)
FROM Table1

WHERE
CreatedMonth = ReportingMonth

GROUP BY
CreatedMonth
Product
ORDER BY CreatedMonth

 

SQL query result

 

CreatedMonthProductSum_Value
FP2021.08XYZ1219
FP2021.09XYZ811
FP2021.10XYZ286
FP2021.11XYZ280
FP2021.12XYZ543
FP2022.01XYZ1412
FP2022.02XYZ561
FP2022.03XYZ586
FP2022.04XYZ300
FP2022.05XYZ304
FP2022.06XYZ382

 

But when created DAX formula

Sum_Created = CALCULATE(Sum(Table1[Value]),Table1[CreatedMonth] = Table1[ReportingMonth])

 

Getting the result from PBI, giving entire total for each month. also,I added reportingmonth to the table even then no change

 

  • Sum_Created = //try this one might help you
    SUMX(
        FILTER(
            Table1,
            Table1[CreatedMonth] = Table1[ReportingMonth]
        ),
        Table1[Value]
    )
    

2 Replies

  • Sum_Created = //try this one might help you
    SUMX(
        FILTER(
            Table1,
            Table1[CreatedMonth] = Table1[ReportingMonth]
        ),
        Table1[Value]
    )
    
  • Anonymous's avatar
    Anonymous
    Not applicable

    thank you so much for quick reply, it worked!!