Add condition to an existing column - powerbi

I have the following columns in my dataset:
_____________________________________________________________________________________
| ... |Start Date| Start Time | End Date | End Time | Production Start Date | ... |
|_____|__________|____________|____________|____________|_______________________|_____|
| ... | 01022020 | 180000 | 02022020 | 190000 | 01022020 | ... |
| | | | | | | |
Sometimes the Start Date + Start Time etc. values are blank but the Production Start Date values are always populated.
When the Start Date is empty (NULL), for example, I want my dataset (or ideally, graph) to read the Production Start Date.
How can I achieve this in Power BI?
I know I can make a conditional column, then within that, determine which column to read data from but is there any way to add a condition to the existing Start Date column? I couldn't see such an option in the context menu or subsequent ribbon options.
Is my only option to create a custom conditional column instead?

As #Andrey Nikolov mentioned in the comments, the only ways you can achieve this is to:
1 Create a calculated DAX column.
2 Create a custom column in query mode (M).
3 Edit the original source table.
doug

Related

Calendar date slicer must automatically select 'Request Start date

below is my query. Kindly help.
I have a table visual in Power BI as below so when I select request id '1' all other visuals in that report page shows the the corresponding data. I have a slicer called 'Calendar date' where it shows date from 2019 to 2022 and user can select whatever dates they want.
My question is when user selects a request id from the below table visual, the Calendar date slicer must automatically select 'Request Start date. Is this possible?
Request id| Request Name| Request start date| Request End date
---------------------------------------------------------------
1 | A | DD/MM/2020 | DD/MM/2021
2 | B | DD/MM/2021 | DD/MM/2022
3 | C | DD/MM/2022 | DD/MM/2023
4 | D | DD/MM/2019 | DD/MM/2019
5 | E | DD/MM/2018 | DD/MM/2018
This feature is currently not possible in Power BI. Lets hope in future this will be available.

DynamoDB single table design for both an "amount" item and separate "amount update entry" items

I am new to DynamoDB and trying to model/index a single table design for tracking a single number value, but with separate update entries for each time the number is changed. Every time the number value is updated, an update entry should be saved to the table (as its own item, not as a property on a single "tracked number" item), and of course the tracked number value should be updated too. I want to be able to query and sort the update entries by date and number change value. And of course I want to be able to look up the current number value.
What is a good single table design for this data and access pattern? I have tried a couple different ways, but find myself blocked because either unable to get/write to a global secondary index, or always returning the item with the current number value when attempting to query on just the update entries themselves. I could very easily create a separate tables for the tracked number and number updates, but that seems to go against DynamoDB principles.
You could create a table with two types of entries:
The current amount with the value's ID as partition key, the literal string CURRENT_AMOUNT as sort key, and an an attribute current_amount that contains the actual value.
The update entry with the value's ID (same as in 1.) as partition key, the timestamp as sort key, and two attributes new_amount and old_amount to represent the changed values.
This way, you can retrieve:
The current amount of an item: pk={{ID}} AND sk="CURRENT_AMOUNT"
The history of an item: pk={{ID}} AND sk <> "CURRENT_AMOUNT"
Both the current amount and the history of an item at once: pk={{ID}}
Additional access patterns can potentially be satisfied using secondary indexes.
Here's an example of what the table could look like with some entries:
-----------------------------------------------------------------------
| pk | sk | current_amount | new_amount | old_amount |
-----------------------------------------------------------------------
| ID1 | "CURRENT_AMOUNT" | 7 |-------------------------|
| | 2020-12-19T14:01:42Z |----------------| 7 | 5 |
| | 2020-12-17T19:07:32Z |----------------| 5 | 9 |
-----------------------------------------------------------------------|
| ID2 | "CURRENT_AMOUNT" | 3 |-------------------------|
| | 2020-12-19T08:01:12Z |----------------| 3 | 7 |
-----------------------------------------------------------------------

Split data into categories in the same row in Power BI

I have a table that contains multiple columns with their named having either the suffix _EXPECTED or _ACTUAL. For example, I'm looking at my sold items from my SoldItems Table and I have the following columns: APPLES_EXPECTED, BANANAS_EXPECTED, KIWIS_EXPECTED, APPLES_ACTUAL, BANANAS_ACTUAL, KIWIS_ACTUAL (The Identifier of the table is the date, so we have results per date). I want to show that data in a table form, something like this (for a selected date in filters:
+------------+----------+--------+
| Sold items | Expected | Actual |
+------------+----------+--------+
| Apples | 10 | 15 |
| Bananas | 8 | 5 |
| Kiwis | 2 | 1 |
+------------+----------+--------+
How can I manage something like this in Power BI ? I tried playing with the matrix/table visualization, however, I can't figure out a way to merge all the expected and actual columns together.
It looks like the easiest option for you would be to mould the data a bit differently using Power query. You can UNPIVOT your data so that all the expected and actual values become rows instead of columns. For example take the following sample:
Date Apples_Expected Apples_Actual
1/1/2019 1 2
Once you unpivot this it will become:
Date Fruit Count
1/1/2019 Apples_Expected 1
1/1/2019 Apples_Actual 2
Once you unpivot, it should be fairly straightforward to get the view you are looking for. The following link should walk you through the steps to unpivot:
https://support.office.com/en-us/article/unpivot-columns-power-query-0f7bad4b-9ea1-49c1-9d95-f588221c7098
Hope this helps.

Syncframework:Map single table into multiple tables

I have two tables like the fallowing:
On server:
| Orders Table | OrderDetails Table
-------------------------------------------------------------------------------------
| Id | Id
| OrderDate | OrderId
| ServerName | Product
| Quantity
On client:
| Orders Table | OrderDetails Table
-------------------------------------------------------------------------------------
| Id | Id
| OrderDate | OrderId
| Product
| Quantity
| ClientName
I need to sync the [Server].[Orders Table].[ServerName] to [Client].[OrderDetails Table].[ClientName]
The Question:
What is the true and efficient way of making it?
I know Deprovisioning and provisioning with different config, is one way of doing it.
So I just wanna know the correct way.
Thanks.
EDIT :
Other columns of each table should sync normally ([Server].[Orders Table].[Id] to [Client].[Orders Table].[Id] ...).
And mapping strategy sometimes changes based on the row of data (which which is sending/receiving).
Sync Fx is not an ETL tool. simply put, it's DB sync is per table.
if you really want to force it to do what you want, you can simply intercept ChangesSelected event for the OrderDetails table, lookup the extra column from the other table and then dynamically add the column to the dataset before it gets applied on the other side.
see this link on how to manipulate the change dataset

Google Chart API table format for charts

Hopefully this makes sense. I will probably just keep mulling this over, until i figure it. I have a table, that is formatted in such as way, that a specific date may have more than one record assigned. Each record is a plant, so the structure of that table looks like the pinkish table in the image below. However when using the Google chart API the data needs to be in the format in the blue table for a line chart. Which I have working.
I am looking to create a graph in the Google chart api similar to the excel graph, using the pink table. Where at one date e.g. 01/02/2003 there are three species recorded A,B,C with values 1,2,3. I thought possibly using a scatter but that didn't work either.
What ties these together is the CenterID all these records belong to XXX CenterID. Each record with its species has an SheetID that grouped them together for example SheetID = 23, all those species were recorded on the same date.
Looking for suggestions, whether google chart API or php amendments. My PHP is below (I will switch to json_encode eventually).
$sql = "SELECT * FROM userrecords";
$stmt = $conn->prepare($sql);
$stmt->execute();
$data = $stmt->fetchAll();
foreach ($data as $row)
{
$dateArray = explode('-', $row['eventdate']);
$year = $dateArray[0];
$month= $dateArray[1] - 1;
$day= $dateArray[2];
$dataArray[] = "[new Date ($year, $month, $day), {$row['scientificname']}, {$row['category_of_taxom']}]";
To get that chart, where the dates are the series instead of the axis values, you need to change the way you are pulling your data. Assuming your database is structured like the pink table, you need to pivot the data on the date column instead of the species column to create a structure like this:
| Species | 01/02/2003 | 01/03/2003 | 01/04/2003 |
|---------|------------|------------|------------|
| A | 1 | 2 | 3 |
| B | 3 | 1 | 4 |
| C | 1 | 3 | 5 |