When asking for help with Power BI, what is the best way to add sample data to the question?
What is the best way to show the relationship between tables?
If the sample data is fairly limited in scope, you should type post it as copyable tables similar to this:
Date ID Value
1/2/2018 101 A
1/8/2018 102 B
1/9/2018 101 B
If the tables and relationships are fairly large and/or complex, then a link to a PBIX file helps us reproduce the issue much more quickly.
The relationships are probably best shown as a screenshot of the Relationships tab from the desktop app. Please also write what columns the relationships are on if it's not clear.
Regarding how to add sample data the most simple way is in my opinion to use a DAX table constructor.
Depending on if you are on a non-American or American machine semicolon (;) is used as separator instead of colon (,), while colon is used as a decimal separator in non-American and dot (.) in American.
American:
{
(1.5, DATE(2017, 1, 1), CURRENCY(199.99), "A"),
(2.5, DATE(2017, 1, 2), CURRENCY(249.99), "B"),
(3.5, DATE(2017, 1, 3), CURRENCY(299.99), "C")
}
Non-american:
{
(1.5; DATE(2017; 1; 1); CURRENCY(199.99); "A");
(2.5; DATE(2017; 1; 2); CURRENCY(249.99); "B");
(3.5; DATE(2017; 1; 3); CURRENCY(299.99); "C")
}
Then it is easy to add this data to a model by just using the New Table-function under the Modeling-tab.
[
And simply pasting the data there.
The downside of this way is that the columns will be named Value1 Value2... ValueN. If this is a big issue one could use DAX DATATABLE in basically the same way as described above.
For sample data in a PBIX file, the easiest way is using the Enter Data feature. You can copy in rows & columns from Excel etc, but the data is self-contained within the PBIX file.
Related
My raw Qualtrics data looks something like this. Basically just 2 questions. Q1-where did you learn your tech skills from? and Q2-Do you agree with the following statement?
I want to plot clustered bar chart in Power BI that looks something like the link below. Basically, for Q1-where did you learn your tech skills from? Each cluster is a channel of learning, and within each cluster there is a standard response from not at all, to a small extent, to a moderate extent, to a great extent, entirely
I figured out I cannot plot straight from the raw Qualtrics data. However, if I unpivot just the columns for Q1, I can get the above clustered bar chart.
But here comes the problem. I have other questions with the same raw Qualtrics format. So I tried to unpivot columns for Q1 FIRST, and THEN unpivot the columns for Q2, and got the following, which does not make sense because Q1 has 4 sub-questions while Q2 has 5 sub-questions. This is like a m:m joins (if I make sense?)
So I thought maybe I could unpivot all the columns except for the Response ID column and I got this
Doing the above has several issues;
the number of rows gets large exponentially and imagine if I have many more questions and many more respondents, the data format just gets too large;
when I want to plot the clustered bar chart, I have no way to restrict the rows just to plot for Q1, or rows just to plot for Q2 etc.
I tried googling and was surprised there isn't a similar question before? given how Qualtrics is very well used for survey data.
Appreciate all your help in advance!
Your first step should be splitting the data from the different questions into separate tables, then "Unpivot Other Columns" but Response ID. You can later relate the tables in the report via this Response ID.
From here creating your column charts should be a no-brainer.
Starting with a list of question identifiers ("Q1", "Q2", ...) you can automate the splitting via a Custom Function
I doubt that with Qualtrics Excel imports you'll come anywhere close to Power BI's data limits. However, I am surprised that they are providing such an awkward interface.
Is there a better way of writing the below DAX formula? I tried using SWITCH, but it didn't like the numerical and text combination.
This data comes from an MS forms survey, and I can't change the survey data source. Also, as it is a live survey I don't want to manually download and transform the data, so I thought using a calculated column would be the best option.
Today: (c) = IF([Today:]="SHELL VALUE", 1, (IF([Today:]="B", 2, IF([Today:]="C", 3,IF([Today:]="D", 4,IF([Today:]="E", 5,IF([Today:]="F", 6,IF([Today:]="CUST. VALUE", 7,0))))))))
Okay, so I'm fairly new to DAX and not 100% sure this can be achieved. I have a table like below...
Current Output :
And I am wanting to merge the 'Latest Weeks and yr ago' into groups such as 'Last 4,'Last 12' etc., this should make the table more readable.
I tried grouping, but each value can only be in one group, and some would need to be in mulitple groups - (ie 'latest 01-04...' would be in all groups). The table above changes dynamically based on a slicer.
What I am trying to achieve is something like this....
What I'm aiming for :
Like I say, not sure it is possible, but hoping someone might have an idea.
Thanks
This is possible but a bit clunky.
One method is to set up a new parameter table to use for your column headers and define your measures to read that context and adjust accordingly. See this related post for an example of how this works.
Another, perhaps simpler, method would be to use calculation groups where Latest X Weeks are your calculation items with formulas along the lines of
---
--- Calculation Item: Latest 12 weeks
---
CALCULATE (
SELECTEDMEASURE (),
DATESTBETWEEN ( DimDate[Date], TODAY() - 12 * 7, TODAY () )
)
Note: You can't create calculation groups in Power BI Dekstop (yet), so you'll need an external tool like Tabular Editor. This is explained in the previous link.
Hello M language masters!
I have a question about working with grouped rows when the Power Query creates a table with data. But maybe it is better to start from the beginning.
Important information! I will be asking for example only about adding an index. I know that there are different possibilities to reach such a result. But for this question, I need an answer about the possibility to work on tables. I want to use this answer in different actions (e.g table sorting, adding columns in group table).
In my sample data source, I have a list of fake transactions. I want to add an index for each Salesman, to count operations for each of them.
Sample Data
So I just added this file as a data source in Power BI. In Power query, I have grouped rows according to name. This step created form me column contained a table for each Salesman, which stores all his or her operations.
Grouping result
And now, I want to add an index column in each table. I know, that this is possible by adding a new column to the main table, which will be store a new table with added index:
Custom column function
And in each table, I have Indexed. That is good. But I have an extra column now (one with the table without index, and one with a table with index).
Result - a little bit messy
So I want to ask if there is any possibility to add such an index directly to the table in column Operations, without creating the additional column. My approach seems to be a bit messy and I want to find something cleaner. Does anyone know a smart solution for that?
Thank you in advance.
Artur
Sure, you may do it inside Table.Group function:
= Table.Group(Source, {"Salesman"}, {"Operations", each Table.AddIndexColumn(_, "i", 1, 1)})
P.S. To add existing index column to nested table use this code:
= Table.ReplaceValue(PreviousStep,each [index],0,(a,b,c)=>Table.AddColumn(a,"index", each b),{"Operations"})
I tried to use the mid and find function in power BI as it can be done in excel. However, I get the error 'find' wasn't recognized.
After searching for a while a have a conclusion that FIND and MID function work in DAX (Excel and Power BI - but not in M query (edit custom) column). Instead of using find, in and M query we should use BIText, PositionOfAny.
Here is an example:
DAX:
MID([TRAFFIC_SIGNAL]), find([TRAFFIC_SIGNAL],"&"),3)
M query:
Text.Combine({Text.Start(Text.Upper([TRAFFIC_SIGNAL]), 3), " ",
Text.Middle(Text.Upper([TRAFFIC_SIGNAL]),
Text.PositionOfAny([TRAFFIC_SIGNAL], {"&"})+1, 3)})
It works so I would like to share because I haven't know the difference between DAX and m query in Power BI before, but this example helps.
I am not sure what you are looking for, but I am just going to highlight the differences between m query and DAX.
M Query:
M query is used to bring the data into the model
This can be accessed using the Power Query Editor
DAX:
DAX is used to create measures and columns after the data is pulled
This is mainly used for summarizing the data
Hope this helps.
M and DAX are entirely different languages used for different purposes.
Primarily,
M is how you get and transform your data before loading to the data model.
DAX is for reading the data in your data model aggregating it to show in visuals.
There are plenty of things you can do with both where it isn't clear which is the better option. It can be highly case-dependent but the above is a simple guide.
In any case, I wouldn't recommend that M code for that purpose. Something like the following should be simpler and more similar to the DAX code:
Text.Middle([TRAFFIC_SIGNAL], Text.PositionOf([TRAFFIC_SIGNAL],"&"), 3)