The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi, so I have two columns depth from and depth to. I need to create a new column called Total depth that:
- has the first row the same as in depth from (30 in this case)
- the rest of rows are copies from the depth to column.
Hi @Anonymous ,
Create a Calculated Column
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
Hi @harshnathani thanks!
There are, however, to issues with this column:
- md_to3 and md_to4 should be equal to Total Depthm4 and Total Depthm5 respectively
- md_to16 (9726,71) is not copied/added to the Total Depthm column.
Hi @Anonymous ,
Make sure that the values are in Don't Summarize form
Use this formula for Calculated Column
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
@harshnathani What if I wouldn't like to change the original data in Query. Can it be done via measure/column in report visualization?
Hi, @Anonymous
Based on your description, you need to create an index column in 'Query Editor'. The pbix file is attached in the end.
Then you may create a calculated column and a measurem, or only a measure.
Calculated column:
Column =
IF(
[Index]=0,
[Depth from],
LOOKUPVALUE('Table'[Depth to],'Table'[Index],[Index]-1)
)
Measure:
Measure 1 =
IF(
ISFILTERED('Table'[Depth from]),
SUM('Table'[Column]),
LOOKUPVALUE('Table'[Depth to],'Table'[Index],CALCULATE(MAX('Table'[Index]),ALL('Table')))
)
or
Measure 2 =
var _index = SELECTEDVALUE('Table'[Index])
return
IF(
ISFILTERED('Table'[Depth from]),
IF(
_index=0,
SELECTEDVALUE('Table'[Depth from]),
LOOKUPVALUE('Table'[Depth to],'Table'[Index],_index-1)
),
LOOKUPVALUE('Table'[Depth to],'Table'[Index],CALCULATE(MAX('Table'[Index]),ALL('Table')))
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous
You may create a measure as below. The pbix file is attached in the end.
Result =
var _stepno = SELECTEDVALUE('Table'[Step No])
return
IF(
ISFILTERED('Table'[Depth from]),
IF(
_stepno=1,
SELECTEDVALUE('Table'[Depth from]),
LOOKUPVALUE('Table'[Depth to],'Table'[Step No],_stepno-1)
),
LOOKUPVALUE('Table'[Depth to],'Table'[Step No],CALCULATE(MAX('Table'[Step No]),ALL('Table')))
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-alq-msft I would need that last value from the Depth to (500) to be at the bottom in the Result column. Can we add step 9 in the step_no column and have 500 value in the Depth to in the same row?
Hi, @Anonymous
You may add a row in 'Query Edior'. The pbix file is attached in the end.
Then you can modify the meaure as below.
Result =
var _stepno = SELECTEDVALUE('Table'[Step No])
return
IF(
_stepno=1,
SELECTEDVALUE('Table'[Depth from]),
LOOKUPVALUE('Table'[Depth to],'Table'[Step No],_stepno-1)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@v-alq-msft measure is working fine, but I've two comments:
- I wouldn't like to change the original data, so could you please suggest how to add this last row in the report vis?
- I've noticed some inconsistency in the data so that I will need this logic in the formula: if a vlaue in the current row is less than a previous value in the row above, replace the current value with that of the row above.
Hi, @Anonymous
You may create a calculated table as below, modify the measure and use the columns from the table to display the result.
New Table =
UNION(
'Table',
ROW("Step No",9,"Depth from",BLANK(),"Depth to",BLANK())
)
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@v-alq-msft the problem is that the number of steps can vary, this time it's 9 but it can be only 3 or 30 next time.
Hi @Anonymous ,
As mentioned by @v-alq-msft . Create a Calculated Table
Incase you want measures instead of Calculated Column to five you the values.
@harshnathani the problem is that the number of steps can vary, this time it's 9 but it can be only 3 or 30 next time.
Hi @Anonymous ,
One solution could be to do it QueryEditor. to create a Table with 1 row in Query Editor. Give that an index value 10000000. And then append this table to the Steps table. This will automate and you will not need to worry till your index in Steps Table reaches 10000000.
For more info I will need to see your data set.
Regards,
Harsh Nathani
@Anonymous ,
Follow the below steps:
Step 1: create index column from Power Query. Go to Power Query editor --> Select any column on which you want to create index lets say "DateColumn" --> Go to Add Column menu --> click on Index Column --> Save and apply.
Step 2: Create below DAX Column:
So directly use the calculated column like below:
@Anonymous you have to have an identifier to find the previous row, again as mentioned in the previous post, some index/id/date column to find out the row if you don't have this in the model you can add index column in power query.
Let's be clear, it is not as straight forward as excel where you can refer to a cell.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.