Forum Discussion

fssebastian's avatar
fssebastian
Frequent Visitor
4 years ago
Solved

How should I use the SWitch function for my two data sources?

I have two data sources, my problem is the If statement is not working in my measure. What I need: I want to use Data A if the Year is Current Year, if not I will use Data B.   Please help.
  • amitchandak's avatar
    4 years ago

    fssebastian , Assuming they are tables. You need a common date/year table then you can create a measure like

     

    if(year(max('Date'[Date]) = Year(Today) , sum(TableA[Value]) , sum(TableB[Value])  )

     

    you need use year/date in visual from date/year table

     

    if needed

    sumx(Values('Date'[year]) , if(year(max('Date'[Date]) = Year(Today) , sum(TableA[Value]) , sum(TableB[Value])  ) )