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.

  • 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])  ) )

2 Replies

  • 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])  ) )

    • fssebastian's avatar
      fssebastian
      Frequent Visitor

      Thank you, my mind just went blank for a minute. This helps. Thank you!