Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
1 year ago

Variable that can be read throughout the project

Hello guys how are you, my question is the following and I've been trying to solve it for a while, I have a report in which there are several tables calculated and almost most of them use this format to update them:


Tbl_BXALLMKTS =
VAR SEM = {45,46,47,48,49,50,51,52,1,2,3,4,5,6}
RETURN
SUMMARIZE (
Data,Data[SEASON], Data[Color],
"BX", CALCULATE(SUM(Data[BX]), Data[Week] in SEM))

I also have this other code with another question:


Tbl_DPT =
SUMMARIZE (
Data,Data[YEAR], Data[Color],
"1", CALCULATE(SUM(Data[Boxes]), Data[Week] IN {1} ),
"2", CALCULATE(SUM(Data[Boxes]), Data[Week] IN {2} ),
"3", CALCULATE(SUM(Data[Boxes]), Data[Week] IN {3} ),
"4", CALCULATE(SUM(Data[Boxes]), Data[Week] IN {4} ),
"5", CALCULATE(SUM(Data[Boxes]), Data[Week] IN {5} ),
"6", CALCULATE(SUM(Data[Boxes]), Data[Week] IN {6} ),
"TOTAL", CALCULATE(SUM(Data[BX]), Data[Week] IN {45,46,47,48,49,50,51,52,1,2,3,4,5,6} )
)

It could be done with a for or while the part of the creation of the fields with the week number, where I give it the initial and final week and I create that part of the code
The idea is not to spend so much time adding the new week number in all the tables and code
Greetings and I hope you can help me
If you don't understand what I asked, let me know and I can give you more details