Forum Discussion
Need help to update existing column
- 5 years ago
You will need to create a new table (under "Modeling" in the ribbon, "New Table") for the samples using:
Sample Table = SAMPLE(5, Cash, 0)The create the following measure:
Yes = IF( COUNTROWS( INTERSECT('Sample Table', 'Cash')) = 1, "Yes", "No")and you will get this:
- 5 years ago
You must be aware that when you create new tables, these are loaded when the whole model is loaded; they are not created "over time".
So you can just directly create one single table with 6 random rows. If there is a specific reason for creating them separately (given that they will be created simultaneaously when the model is loaded), then you can create a new table for one row and use UNION to append them.
Hi PaulDBrown
Can you give me a few pointers on how to accomplish that using measure? Thank you for all your help.
Happy to help, but please provide sample data or better yet a sample PBIX file (so that we can work on the solution) and a depiction of the expected outcome
- siumui5 years ago
Helper I
Hi PaulDBrown
Cash table
Attached is my Cash table data. I select 5 random records from the Cash table above using SAMPLE() with the codes below:
SampleCash = SAMPLE(5, Cash, 0)
The SAMPLE() returns 5 random records with ID of 2, 8, 11, 17, 18. So my goal is to update the Cash table that has the record ID of 2, 8, 11, 17, 18 where the Sample column will be update to "Yes". See example below of expected outcome.
Thank you for your help.
- PaulDBrown5 years ago
Community Champion
Try:
Yes =
Var samples = SAMPLE(5, Cash, 0)Var _table = Cash
Var _rows = COUNTROWS (INTERSECT( samples, Cash))
RETURN
IF (_rows = 1, "Yes", "No)
- siumui5 years ago
Helper I
Hi PaulDBrown
I'm happy to hear from you! Happy Friday!!
Quick question, where do enter the codes you've written? I'm a little bit lost. Do I enter it in Power Query Editor? Data View? Please let me know.
Thank you