Filter PowerBI Measure Based on Column - powerbi

I am trying to set up a dashboard with data that looks similar to this:
As you can guess, all of the 'rate' columns are related. I know to create a graphic that shows the totals for all 'rates' I first need to create a measure that is the sum of these 4 columns. My question is, how do I filter that total, based on the columns in the measure?
For example, if I had a line graph for the 'totals' measure:
Is there any way to create a filter visual that would allow me to see just the AA rates on this graph (that is, only measure the sum of the AA rates) or just the UA rates, etc.? Or is there a way to put all 4 columns on the same graph...
and then create a filter visual so single out one of the values fields?

Related

Using IN operator in DAX with Power Bi Desktop chart?

I'm new to DAX so please bear with me.
Can I use the IN operator in DAX to create a query directly in Power Bi desktop?
For example, the screenshot below displays over 120 curencies in DimCurrency.CurrencyName. Is it possible to create a DAX query where I can include all my filters using IN operator?
For example, maybe something like this?
CALCULATE (
[Sales Amount],
Products[Color] IN { "Red", "Black" }
)
The reason I'm interested in using DAX is because my current filter has over 200 different items, so I don't want to scroll through the 200-item list and select 5 different items.
This is a data modeling problem. In Dimensional Modeling terms your Dimension needs some additional attribute hierarchies to drive the filtering. This is just like why a Calendar table doen't just have a Day column, it needs Month, Year, Quarter, so you don't have to select all the individual Days.
Basically DimCurrency needs an additional column, so that you can include those 50 currencies by selecting fewer values of that new column.
One way to modify your data model is with DAX calculated columns, with an expression of the form
IsFacoriteCurrency = 'DimCurrency'[CurrencyName] in {"Algerian Dinar","Argentine Peso"}
you can also modify the data model in the data source or in Power Query.

In Power BI, how can I create a column that changes based on a slicer and visualization?

I'm pretty new to Power BI. I'm unsure how to approach this.
I have one visualization that displays the ten most frequently bought products in a time frame that is set by a slicer. In another visualization, I display how those products have been selling over the past few years (this time frame is not determined by the slicer). I want to display only the ten products that come from the first visualization, not the ten most common over the time frame in the second visualization.
How can I accomplish this? The approach I have in mind (and I'm open to others) is to create a true/false column that changes with the first visualization. "True" would be for products that are frequently bought as determined by the first visualization in the slicer-determined time range, and the second visualization would only look at values with a "true" in that column. How can I create a column (or table, maybe?) that changes depending on a visualization?
Clarification: most of the pages will say Top10 ... Actually, the measure used was a simple Top5 that includes products with the same number of orders than the 5th product. Therefore, to avoid dealing with larger images, 7 products will be seen but it is a Top5 ranking. The idea is you can replace it with your custom TopN measure.
What I understood:
The simplification of your model plus the disconnected help table would be:
I have one visualization that displays the ten most frequently bought
products in a time frame that is set by a slicer.
The Date slicer belongs to the Dates table in the Data model.
The table viz represents the number of rows in the sales table in the
current context (for each product within the Date range).
The table viz is sorted according to the [#Rows] measure in descending
order.
The table viz only presents the TopN products even without the presence
of the [#Rows] measure due to the presence of the [TopOrders]
measure within Filters on this visual. [TopOrders] is 1.
On the second page you create:
A slicer with the Dates[Date] column (the same one used on the
previous page).
A matrix with Products[ProductName] on the rows, HDates[Year] on
the columns, and a measure on values.
From the View tab, you select the Sync Slicers option.
Inside the Sync Slicers pane:
In the Sync column, check the boxes related to the necessary pages.
In the Display column uncheck the box that contains the over
years report.
So far all we have done is pass the time frame context from page 1 to page 2.
Since the TopN context depends on the time frame context, we can now use the [TopOrders] measure as a Filters on this visual in the matrix. Again, [TopOrders] is 1.
Why do the numbers differ between rows and not between columns?
Also, in this example, the Sales table only has information up to 12/31/2020 but the visualization shows an additional year and the Sales[Amount] values for each order is $1 so that [#Orders] and [SalesAmount] are the same for easy comparison.
HDates is not related to the model and for each combination of HDates[Year]-Products[ProductName], the [SalesAmount] measure is using the information coming from the previously hidden slicer and the respective Products[ProductName] because the information coming from HDates[Year] has no effect yet.
In order to complete this exercise, it only remains to modify the [SalesAmount] measure in such a way that it removes the filter on the time frame (Dates[Date]) and it recognizes HDates[Year] as Dates[Year].
SalesAmount :=
CALCULATE(
SUM(Sales[Amount]),
ALL(Dates),
TREATAS(VALUES(HDates[Year]),Dates[Year])
)
And this is the final result.
I hope it works for someone or the idea can be improved.

Calculate % of two columns Power BI

I want to calculate % of two columns which are already in %.
I want to calculate formula like
Target achieved= ACTUAL/TARGET
But here is ACTUAL is already a measure/calculated metrics so I'm not able to divide these two columns.
Any help would be appreciated..
Make sure both target and actual are actually numbers and not strings. You can do it in transform data (aka Power Query) part, before data is loaded into the report.
After that you should be able to create the measure you want, e.g. something like that:
UPDATE : What happens if Actual is not a column, but a measure?
If Actual measure is based on the columns in the same table as target you shouldn't have a problem. You cannot combine measure and column in the same formula. Measure is an aggregated field and needs to be grouped by another field (if you are familiar with SQL,think of SUM and GROUP BY). Coming back to your problem, you need to create measure out of "Target" column as well (notice I have in the formula SUM('Table'[Plan]) which makes it a measure). Than you can use both of them in the formula, but of course you need to "group" them by something(e.g. date) otherwise it will just show you a total.

Calculated column in Power BI that repeats different sums based on conditions in 2 other columns

I need a calculated column based on conditions in two columns (Business Unit Number in both tables and L1/Account Categories in 1st table and the second table) which sum and then repeat for several rows before the conditions change and a new sum is repeated for several rows and so on. The L1/Account Categories columns have different names because it's the raw data.
For example, any time ASSETS and 111 appear in the same row, I would want to use those as conditions and with the sum of all of the other matching rows in a new column and the sum would repeat each time both conditions appeared in the same row. Any time P/L and 111 appear in the same row, that would be a sum of all other P/L and 111 appearances in the dataset (about 1000 rows overall)... and so on.
I've tried formulas with DAX using FILTER, SUMX, nested IF statements and also tried the Power Query language among other attempts. Maybe I have to create one or more than one new table? If you need to take a look at a few of my attempts, just let me know.
The top image is how I imagine the output will look in the power query editor and the bottom image is a sample of the source data.
This last pic is from Tableau - I need to make a table in Power BI which essentially a duplicate of this image. The last 2 columns are pulling from different tables.
This should be very simple to achieve with relationships and measures - no need for calculated columns or power query merges. You need to build a relationship between these two tables. In fact, I would introduce a third table in your model for Business unit.
The limitation of Power BI model relationships is that they can only be based on a single column. So to build a relationship between these two tables you would have to add a calculated column in both of them that would contain both a BU and the financial statement line, for instance: JoinCol = CONCATENATE([Business_Unit_Number], [L1]). Then you could create a relationship and do what you want.
The better (one that I would recommend) approach would be to separate Business Unit into a separate table and have relationships built like this:
Then all you have to do in your visual is drag Business unit name from the BU table, L1 from the FS Lines table and a measure to sum the amounts Amount = SUM('Financial Data'[Rolled Up Detail]).
Here is a working sample: https://1drv.ms/u/s!AmqvMyRqhrBpgtUT5HKnZP1U3Gzc9w?e=en91dV

Is it possible to get a percentage of data, from an OData source, in Power BI?

I'm still very new to Power BI, so forgive my possible ignorance.
We need to do a quarterly check-up, on some data.
To get this data, we have an OData endpoint.
Some of the checks require us to get a random sample of data, from within a certain time.
The random sample of data could be something like: "a random 20% of all papers from 01-01-2020 to 01-02-2020".
I'm not sure if this is possible in Power BI.
If possible, I don't know if I need to adjust my query or do these calculations after getting all the data.
You may use RAND() in DAX as a calculated column or a measure (RAND in a measure is not always recalculated as it is volatile).
You can add an index column to your table in power query then apply query changes to load the updated table.
Next step , create a measure :
ramdom mymeasure = RAND()
and add desired fields to a table including the index column that you choose by your logic.
Go to
Visualizations pane > Fields > Visual level filters>
Selected Top N under filter type >Show Top 20 items> Drag random measure to By Value.