Forum Discussion
Replacing Excel Columns with DAX
I have a following excel table. Adjustment Date, Value, TriggerPoint, and Index % are original columns. I was trying to compute "Triggered", "Baseline" and "Movement" columns using Dax in Power BI, logics for those columns in Excel are in Column F, H, and J respectively.
A | B | C | D | E | F | G | H | I | J |
Adjustment Date | Value | TriggerPoint | Index % | Triggered | Triggered Formula | Baseline | Baseline Formula | Movement | Movement Formula |
| 9/1/2021 | 1.914 | 10% | 115.70% | 1.6 | 1.6 is given | ||||
| 11/1/2021 | 2.281 | 10% | 134.10% | Y | =IF(ABS(I3) > C3, "Y", "N") | 2.281 | =IF(E3="Y", B3, G2) | 42.56% | =B3/G2-1 |
| 3/1/2022 | 2.311 | 10% | 135.60% | N | =IF(ABS(I4) > C4, "Y", "N") | 2.281 | =IF(E4="Y", B4, G3) | 1.32% | =B4/G3-1 |
| 6/1/2022 | 2.304 | 10% | 135.20% | N | =IF(ABS(I5) > C5, "Y", "N") | 2.281 | =IF(E5="Y", B5, G4) | 1.01% | =B5/G4-1 |
I spent almost entire day but couldn't figure it out. Can someone help me out? Any help will be appreciated!
2 Replies
- AnonymousNot applicable
Hi, Anonymous
Based on your infomation, I create a table.
After importing the data into Power BI, create a calculated column called Index to sort the data.
Index = RANKX( ALL('Table'), 'Table'[Adjustment Date], , ASC, Dense )Next, create three measures as follows
Triggered Formula = VAR _Movement = IF( ISBLANK(SUM('Table'[Movement])), BLANK(), CALCULATE(SUM('Table'[Movement]), 'Table'[Index]) ) VAR _TriggerPoint = CALCULATE(SUM('Table'[TriggerPoint]),'Table'[Index]) RETURN IF( ISBLANK(_Movement), BLANK(), IF(_Movement > _TriggerPoint, "Y", "N") )Baseline Formula = VAR _Triggered = IF( ISBLANK(CONCATENATEX('Table', 'Table'[Triggered], ", ")), BLANK(), CALCULATE(CONCATENATEX('Table', 'Table'[Triggered], ", "), 'Table'[Index]) ) VAR _Baseline = CALCULATE(SUM('Table'[Baseline]), 'Table'[Index]) VAR _Value = CALCULATE(SUM('Table'[Value]),'Table'[Index]) RETURN IF( ISBLANK(_Triggered), "1.6", IF(_Triggered ="Y", _Value, _Baseline) )Movement Formula = VAR _Baseline = CALCULATE ( SUM ( 'Table'[Baseline] ), FILTER ( ALL ( 'Table' ), 'Table'[Index] = MAX ( 'Table'[Index] ) - 1 ) ) VAR _Value = CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Index] ) RETURN IF ( ISBLANK ( _Baseline ), BLANK (), ( _Value / _Baseline ) - 1 )Here is my preview:
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Thanks for replying! It seems you wrote Measures assuming "triggered" OR/And "Movement" columns are given in the dataset. In fact, Both of those shuould be calculated fields. However, you are supper close to the solution. Here is the actual file I was trying to replicate which will give you more context. https://docs.google.com/spreadsheets/d/1cxwcT1ayWMaCzeD08It_vaRQZcys4WVM/edit?usp=sharing&ouid=110109939970385997421&rtpof=true&sd=true