Forum Discussion

Sekhar1's avatar
Sekhar1
Frequent Visitor
3 years ago
Solved

Unable to calculated difference using DAX

Hi,  I am getting error while trying to calculate difference between weeks. Please see below sample table    Year Year and Week No Quarter QuarterInYear Totals Date 2022 2022_WK07 Q1 ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Sekhar1 ,

     

    According to your statement, I think the relationship between the column will cause this issue.I suggest you to create two unrelated slicer tables with [Year] and [Year and Week No] columns you need.

    Data model:

    Measures:

    Sum of Total 1 = 
     CALCULATE(SUM('Table'[Totals]),USERELATIONSHIP('DimDate 1'[Date],'Table'[Date]))
    Sum of Total 2 = 
     CALCULATE(SUM('Table'[Totals]),USERELATIONSHIP('DimDate 2'[Date],'Table'[Date]))
    Difference = 
    [Sum of Total 1] - [Sum of Total 2]

     Result is as below.

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.