Forum Discussion
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
- amitchandakSuper User
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]) ) )
- fssebastianFrequent Visitor
Thank you, my mind just went blank for a minute. This helps. Thank you!