Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I am trying to create a new column as follows:
DeductionFlag =
SWITCH(TRUE(),
CONTAINSSTRING(RELATED(IATAFareBasis[iatafarebasisCode]),"IN") && CONTAINSSTRING(RELATED(FareReduction[FareReductionCode]),"AD"),1,
CONTAINSSTRING(RELATED(IATAFareBasis[iatafarebasisCode]),"AD") && NOT( CONTAINSSTRING(RELATED(IATAFareBasis[iatafarebasisCode]),"AD50")),1,
CONTAINSSTRING(RELATED(IATAFareBasis[iatafarebasisCode]),"ID") && NOT( CONTAINSSTRING(RELATED(IATAFareBasis[iatafarebasisCode]),"ID50")),1,
CONTAINSSTRING(RELATED(IATAFareBasis[iatafarebasisCode]),"BP") && NOT( CONTAINSSTRING(RELATED(IATAFareBasis[iatafarebasisCode]),"BPR")),1,
RELATED(IATAFareBasis[iatafarebasisCode]) = "Y" || RELATED(IATAFareBasis[iatafarebasisCode]) = "N",1,
RIGHT(RELATED(IATAFareBasis[iatafarebasisCode]),2)= "DH",1,
CONTAINSSTRING(RELATED(IATAFareBasis[iatafarebasisCode]),"RG90") || CONTAINSSTRING(RELATED(IATAFareBasis[iatafarebasisCode]),"RG75"),1,
RELATED(FareReduction[FareReductionCode]) = "IN" || RELATED(FareReduction[FareReductionCode]) = "TS" || RELATED(FareReduction[FareReductionCode]) = "PS",1,
Related(FareType[FareTypeKey]) = 55 || related(FareType[FareTypeKey]) = 134,1,
'Pax Revenue'[PAX_Rev excl_YQ ( EUR )] =0 ,1,
0)
Basically, I need that deduction flag to build measures in the model.
However, I am encountering a memory issue when the above code runs.
The culprit seems to be 'Pax Revenue'[PAX_Rev excl_YQ ( EUR )] =0 ,1, which makes my laptop run out of memory.
When I remove this condition the rest of the code works fine and I have no memory issue.
[PAX_Rev excl_YQ ( EUR )] is a calculated column in one of my fact Tables.
Is there any way I can resolve the above apart from adding more memory to my laptop?
Thanks
Veemal
Solved! Go to Solution.
@VeemalS can you use variables and store the calculation results in variables and try using variables inside SWITCH?
The code has been changed as follows:
@VeemalS can you use variables and store the calculation results in variables and try using variables inside SWITCH?
The code has been changed as follows:
Hi,
Regarding optimization, this kind of formula is extremly "heavy". RELATED and CONTAINSSTRING are some of the more non-optimized formulas and calculated columns are not optimal in terms of memory usage. If possible I would try to apply your desired logic into a formula. To do this a more clarified explanation on what you are trying to achieve is required.
Proud to be a Super User!
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
7 | |
7 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |