Extract data from JSON field with Power BI desktop - powerbi

I'm using Power BI desktop to connect to a MySQL database.
One of the fields contains data with the following structure:
a:1:{s:3:"IVA";O:8:"stdClass":3:{s:11:"tax_namekey";s:3:"IVA";s:8:"tax_rate";s:7:"0.23000";s:10:"tax_amount";d:25.07000000000000028421709430404007434844970703125;}}
I need to transform the data in a way that allows the extraction of the value of the tax amount. That is, I need to transform this column to: 25.07.
How can I do this? I tried splitting the column by semicolon, but since not all the columns have the same number of semicolons it didn't work.
Thanks in advance!

Use this function
Works only for your task - parse number 25.07 from source string
(src) => Splitter.SplitTextByEachDelimiter({";d:",";"})(src){1}

The value in the column is not actual JSON file .There is option in power bi itself to split json column but it should be valid json.To check whether is a json file or not try using the link
https://jsonformatter.curiousconcept.com/
After that go to edit query right click on the json column and transform-> JSON .
It will transform your json file into columns.

Related

Is there a way to create a char(13) delimited string that can be used in Power BI?

I am creating a report in Power BI and would like to create an client address string that is formatted as a standard line-delimited postal address in the United States.
I tried creating a DAX measure, but could not get around the error:
A single value for column 'ServiceAddress1' in table 'pbiCoverPage' cannot be determined.
This error occurs if I try to use the DAX TRIM function on any TEXT column for a Measure.
As a workaround, I created a SQL View that returns a CHAR(13) delimited string with a postal address.
However, if I display the field in a card visual, the CHAR(13) do not create separate lines. The postal address is displayed on a single line with the CHAR(13) interpreted as a spaces.
My questions are:
Can text fields be used at all in DAX Functions such as TRIM in a Measure?
Is there a Power BI Visual, other than 'Card' that can display text on a report?
Displaying a postal address should not be a difficult task. Is there a simple way to do this in Power BI?'
Is there any way to use a Text Box in Power BI to show a field value? I think this would allow me to left-justify the address string.
If I try to add a Value to a text box, I get a message:
To turn of Q&A, we need to create a local index of your data. If you publish the report, we'll one in the service as well.
I am researching this message. It seems like I am driving a tack with a sledge hammer. Is there an easier way to display a formatted text string in Power BI?
I tested the following approaches:
Use a Button. The button supports text alignment and has word-wrap. However, it does not support line delimiters such as CHAR(10) or CHAR(13).
Use the HTML Content Custom Visual from:
https://www.html-content.com/
The HTML Content control allows you to write SQL Queries that return HTML that includes the <br> line-break tag.
Thus far, the HTML Content visual is the only way (short of a custom R or Python visual) to display a string (such as a postal address) with multiple delimited lines in Power BI.

Can Query Builder in SAS EG be used to output fixed-width columns?

thanks for any help! I’ll try to be concise.
I am new to SAS and have inherited a SAS run that outputs a table with 15 columns, which I export as an excel file and deliver.
The recipient would now like it as a .txt file with fixed-width columns, and has provided the character limit/width for each column.
Is this something that can be done in query builder, so I can just query the existing table rather than modifying the code in the run? I tried filling the field for ‘Length’ when you add a column to query builder, but it did not have the desired result.

How to make a text column in power bi dataset a numeric value

I am working on a report and updated the power bi dataset with the most recent data. However, for some reason a column is recognizing the data as a string instead of numeric. I checked the excel file it is updated from, but in the excel file the column is considered numeric. Any idea how to fix this, as i cant use the data as a string. In addition, it would be beneficial if there was a way to change the dataset to just using the excel file, instead of having to use power bi datasets, is there any way to do that as well, as when i try to change datasets in only lets me view power bi datasets.
Thank you!
In Power Query change the datatype to numeric.

Upload value list text file on power bi filter

I have created a power bi pro (online) report.
This report contains a filter. This is a basic text Input, linked on a field.
Here is what i want to do: i want to type several values (with a separator) and I want to filter all rows whose value match.
I have a very large number of possible values. The user can type about 100 values. Is it possible for the user to send a text file instead of typing values in filter ?
Thanks

Format date field in Power BI service

I have imported an Excel file to Power BI service from my OneDrive for Business.
The file contains a simple Excel table and one of the fields is a date.
Now, in Power BI service, I get that field displayed as a whole number which isn't very useful to read in a report.
How do I change the field to display as date?
Thanks!
We can use FORMAT() method to format date value, Use below mentioned formula
Syntax: Column = FORMAT(Table[column],"MM/DD/YYYY")
Column = FORMAT(DailyActiveUsers[startDate],"MM/DD/YYYY")
Before my data:
After my data:
This usually works by default for true Excel dates. Anyway, just open the Edit Queries window and navigate to your table. In the column header for your Date, change the Data type to Date. Close & Apply to see the result in your report.