How to dynamically change column source of a card to another one in Power BI - powerbi

For a report in Power BI I have two column with name 'A' and 'B'. I want to show summation of values of column 'A' or 'B' in one card based on the selection of the user.
I Want to know can I change column source of a card in report view in Power BI. A simple solution is to have two cards, each one for each column. But I want one card such that the user defines source column of it.
Thanks

First you have to see if you have any data that helps you to identify if column A or B is selected.
If you havn't you can create an auxiliar table as I did to this solution like this:
Use this column to create a filter visualization
Then create the following DAX measure:
SUM = IF( SELECTEDVALUE( AuxTable[Auxiliar] ) = "A", SUM('Table'[A]), SUM('Table'[B] ) )
Don't forget to change the select options on your filter visualization to only be able to select 1 option if is necessary.
Hope it helps you.

Another possible solution without using DAX is to take advantage of Buttons and Bookmarks.
In your scenario, you could create a Button corresponding to the possible use choices. When the user click on one button it will direct to the bookmark showing the visualization calculated using that data source.
In practice, this means you will have two Cards in your report, but only one visible at a time.

Related

How can I force only two selection out of 5 available on slicer visual?

Can someone please help me get a fix for this please.
I want to let people make only two selection at a time, no more no less from the given options. The intention is to get data on matrix dynamic column based on these two selections.
Thanks
Avi
You did not make clear what the purpose of this exercise is and how the result should look like ("get data on matrix dynamic column"), but you could
Create 2 single selection slicers based on copies of your category column
Make sure they are not related to the rest of your data model
Get the selected rows via the SELECTEDVALUE() function
You may have to consider the case where both selections are the same.
This would be a feature of a slicer visual, but I don't know of any built-in or custom slicer visual that does this.
As a workaround you can show a warning and instruction to select two items, eg a big Card visual with red text and a transparent background in front of your other visuals displaying a measure like:
AreTwoCategoriesSelected =
IF (
DISTINCTCOUNT ( DimProductCategory[ProductCategoryName] ) <> 2,
"Select 2 Categories for this report",
""
)
Which might look like
and
You can't easily use the trick where you have the measure conditionally return BLANK because most evaluations of the measure will have a filter context with just one of the selected values.

How to add calculated column to existing table that would ignore selected value in a slicer Power BI

I need to add calculated column that would ignore values selected in a slicer:
I tried:
all users = ALL(Sheet1[UserName])
But it gives me an error: A table of multiple values was supplied where a single value was expected.
A calculated column cannot be affected by a slicer but that's not what you seem to be referring to.
It appears you are trying to create a visual that lists all the users. For this, you can put Username on a table visual and disable the filtering from the slicer by going to the Format tab and clicking Edit interactions.
If I understand you correctly, You have to use ALL() Function by
creating new table Under the modelling tab

How to add multiple fields in columns of Power BI matrix and view them without drilldown

I've trying out Power BI to solve some visualization problem in my organization and I've been working on desktop version of Power BI to try out its features.
I'm stuck at few issues and cannot find our way out of this.This is a sample view I've been trying to create:
Figure 1:
1
We've a dataset containing Product Opinion across gender, Age Group, Geography etc. and we want to pivot the opinion across different parameters as shown above.But when we use Matrix view of Power BI and add two parameters in columns, it creates a drill down view as shown below:
Figure 2: 2
On adding multiple fields in the column section we get an option to move down to next hierarchy as shown below:
Figure 3:3
Although we have the option to move down to hierarchy ,we are unable to show then side by side as we've shown in Figure 1.
Is there a way we can get the visualization as given in Figure 1 ?
Also, Currently the columns and rows are automatically sorted alphabetically. Is there a way we can adjust the column and row position as per our needs?
To sort the rows in a custom order, you will have to create an index table. The below link walks you through the steps involved:
http://www.excelnaccess.com/custom-sorting-in-power-bi/
Now, to achieve the visualization you are looking for, the only way I can think of is to create two matrix visualizations (One for gender and other for age group) and place them in such a way, that it gives the illusion of the same table. There might be a better way to do this, but I these workarounds work just fine. Hope this helps.

How can I have dynamic axis which is responsive on slicer value, without using bridge table, use just DAX

Hi everyone, I have a chart which I need that the x value (Axis) changes by changing the slicer value (this slicer is the yellow one that has all the Dims (x values)) and it comes from DimList table. For example, at the moment the chart is totalfreight by custid, but I need if I check the empid from the yellow slicer the chart value changed to totalfreight by empid. This happens for all of the slicer values.
But I don't like bridge table or any method that has a bad effect on performance because the FactTable has a billion rows and I modeled it in SSAS, tabular model and has a live connection. Thanks in advance.
I assume you're referring to the approach that uses a bridge table described in this article. I agree that you may face some performance problems given the amount of data in your model.
First of all, you should try to see if there's some other Power BI frontend functionality that you can use directly in the report, without changing your data model. Perhaps you can use Power BI bookmarks, links or maybe a custom visual?
If not, there's another approach you can use in the data model, that does not rely on bridge tables. Disclaimer: I haven't tested this - there could be other performance issues involved.
Construct a new dimension table with all the members from your individual dimensions. Ie. create a union of all EmpIDs, CustIDs, etc. Make sure you indicate the type of ID in a separate column. The table should look like this:
DimensionId MemberId
categoryid 1
categoryid 2
categoryid 3
custid 1
custid 2
custid 3
...
Let's name this table 'All Dimensions'. The table should not have any relationships to other tables (this is similar to the Parameter Table pattern.
Change your measures to apply a virtual relationship whenever something is selected on the 'All Dimensions' table, to properly filter the fact table:
SUM('factSale'[Freight])
would become:
SWITCH(
SELECTEDVALUE('All Dimensions'[DimensionId]),
"categoryid", CALCULATE(SUM('factSale'[Freight]),
KEEPFILTERS(TREATAS(VALUES('All Dimensions'[MemberId]), 'factSale'[CategoryId])),
"custid", CALCULATE(SUM('factSale'[Freight]),
KEEPFILTERS(TREATAS(VALUES('All Dimensions'[MemberId]), 'factSale'[CustId])),
"empid", CALCULATE(SUM('factSale'[Freight]),
KEEPFILTERS(TREATAS(VALUES('All Dimensions'[MemberId]), 'factSale'[EmpId])),
// ... etc. for all dimensions ...
, // Fallback, when nothing is selected on 'All Dimensions'
IF(NOT ISFILTERED('All Dimensions'[MemberId]),
SUM('factSale'[Freight])
)
)
Put the [DimensionId] column into a slicer and use the [MemberId] column as the axis on your bar chart. Note that the chart will not show anything unless exactly one item has been filtered on the [DimensionId] slicer.
Explanation: The SWITCH statement determines if any selection has been made on the [DimensionId] column of the 'All Dimensions' table. In that case, a filter is applied to the fact table, depending on which dimension has been selected, using the TREATAS function. We're using KEEPFILTERS to make sure that any existing filters made directly on the individual dimensions are kept as-is.
In case no selection has been made on the [DimensionId] column, we want to fall back to the standard measure SUM('factSale'[Freight]) but since we don't want to repeat this measure for all items on the [MemberId] column, we use IF(NOT ISFILTERED( ... to make sure that we return only a blank value, if [MemberId] is currently used on the chart axis.

Merge or combine two columns in power bi

I am not sure if my title is correct one, but here is the deal:
I want to make a matrix visualization in Power Bi Desktop. I have fields: ARTICLE_ID and ARTICLE_NAME.
I would like to have both those fields in COLUMNS position in matrix data view. And I need them to be in one row, no need to drill down... because it is one and the same thing...
I need to have ARTICLE_ID and ARTICLE_NAME as two separate columns on the same level. without drilling. And also, I dont want to use concatenation or merging into some third column. is that possible? thanks
1) I started with this sample data.
2) I created a matrix and configured it as shown in the image below.
3) I clicked the forked arrows to show all levels.
4) In the Rows section of the formatting pane, I turned off "Stepped layout".
5) In the Subtotals section, I turned off "Row subtotals".
I don't know if this is exactly what you are looking for, but I think it is the closest I can come up with since you don't want to concatenate the columns together.
If they are from the same table then just drag and drop them into the columns.
The way a matrix works from my understanding in PowerBI is;
Rows are just the headings/categories of the values.
You might need to also go into the format tab, values, and make sure show on rows is on.
For example, let's say our value headings are rainy days and sunny days.
Your columns are months.
The rows will be the 2 categories.
The values will be the values.
As concatenation and "&" does not work in Power BI directquery you can use the below one:
[New_column_name] = if((table_name[column_name]="A" && table_name[column_name]="B"),"AB","NA")
Thanks,
Sachin Kashyap