I am fairly new to PowerBI and have a situation at hand.
I have a column on which I have to create two parameters and compare the values against each other.
Example:
Animal: Food: Capacity:
Dog Milk 10
Dog Bone 26
Cat Milk 20
Cat Bone 8
Bird Grain 6
Bird Water 9
When I select Parameter1 as Dog and Parameter2 as Cat, I should get something like this:
Food: CalcMeasureDog CalcMeasureCat<br>
Milk 10 20
Bone 26 8
Is this something we can achieve in PowerBI?
Main challenge is to use the Parameters in the calculation to do the below:
CalcMeasureDog=IF(Animal=Parameter1,Capacity,0)
CalcMeasureCat=IF(Animal=Parameter2,Capacity,0)
Also, I don't really want to show the animal column on the report on which i have the parameters created.
Appreciate any help i can get.
First, create a measure for all animals:
Total Capacity = SUM(Table[Capacity])
where Table is the name of your table.
Then, create measures for specific animals:
Dog Capacity = CALCULATE( [Total Capacity], Table[Animal] = "Dog")
Cat Capacity = CALCULATE( [Total Capacity], Table[Animal] = "Cat")
If you drop these measures into a matrix with food on the rows, you should get your desired result.
The simplest way to do this is to just put them all in a matrix visual with Food on the rows, Animal on the columns, and SUM(Table[Capacity]) as the values and use a single slicer for both parameters:
I'm not sure how well this works for your particular report as I don't quite understand what you meant by
I don't really want to show the animal column on the report on which i have the parameters created.
Related
I am trying to calculate market share, but struggling with doing it correctly.
I have a matrix where I have Category, Name as rows, Channel as column, and Market Share as value.
Also In my dataset I have columns ABS_COMPANY (with sales inputted there if company = "A", so there are some blank ones), and ABS_TOTAL (with sales inputted in each row)
so my measure Market Share:
Market Share = SUM(table\[ABS_COMPANY\]) / SUM(table\[ABS_TOTAL\])
This correctly calculates values for each Category, but when I open the drop-down to see Name, Market Share of each Name equals to 100%. What is the problem and how to fix it?
e.g. What is now:
Market Share
Pens 43%
pen 1 100%
pen 2 100%
pen 3 100%
Pencils 29%
penc 1 100%
penc 2 100%
penc 3 100%
I've tried using Calculate(), but it does not work in a way I want to.
Unfortunately, I cannot share the data as it is sensitive.
Structure of dataset:
NAME STRING
CATEGORY STRING
CHANNEL STRING
ABS_COMPANY DECIMAL(20,2) - value of sales for each name
ABS_TOTAL DECIMAL(20,2) - it is a value grouped by CHANNEL AND CATEGORY at the backend
I'm practicing my Power BI skills. I've downloaded a csv file which contains data about olympic games. The dataset has many columns, such as country, athlete name, year, sport, event, medal which the athlete has won, olympic city, etc.
The problem is that I want to create a bar graph that display country name by medal types count. However if create a graph "Country" by "Medal" from original csv it will not display the correct numbers of medals, because if a country wins a medal in a team sport (like volleyball or football) it should count as only one medal, and not the sum of all medals of all athletes in that team. This could be solved by removing Athlete column and selecting distinct values of "Event" column, like creating a table using the following formula:
Table 2 = CALCULATETABLE(ALLEXCEPT('summer (3)','summer (3)'[Athlete]),DISTINCT('summer (3)'[Event]))
However, I don't want to create a new table, because I would have serious problems with relationship between them (I have no idea how to do it, to be honest). So I want to create a measure. I created the following measure:
Medal count = COUNTX(CALCULATETABLE(ALLEXCEPT('summer (3)','summer (3)'[Athlete]),DISTINCT('summer (3)'[Event])),'summer (3)'[Medal])
It is showing the correct number of all medals in olympic games history (untill 2012). However, for every country, its showing the number of gold medal, silver medal and bronze medal with the same number (the total number of olympic medals 14753). It's not filtering by the number of rows for that specific country.
The same number also appears if I select any medal type from filter option (Gold, Silver or Bronze).
I have no idea how to fix this. How can I create a measure that shows the correct number of medal type for every country?
This is what I would do. First I will create an "id" column if I haven't had that, then I will do the distinctcount on that.
The DAX for the id column should be something like this:
debug_id = CONCATENATE(Table['Year'],CONCATENATE(Table['Sport'],CONCATENATE(Table['Discipline'],CONCATENATE(Table['Country'],CONCATENATE(Table['Event'],Table['Medal'])))))
then you can basically drag and drop this field onto the x-axis (y-axis and legends stay the same) and select Count (Distinct). If you really want the measure for this, it should be quite straight forward like:
Medals count = DISTINCTCOUNT(Table['debug_id'])
Hello I m newbie in dax ,
I want to calculate the max of value by subcategory and category.
it s like Max(Max(subcategory)category ) this example explain what I need .
Category Subcategory value
animal lion 5
food tomato 4
food potato 6
animal dog 5
plants flower 2
Category Max value
animal 5 ( if we have 2 subcategory with same value he choose randomly one )
food 6 ( potato )
plants 2
example
In Power BI, you do not have to calculate anything. You can simply use a visual to get teh result you want. Import the data, drag the table-visual on the report. Drag the Category and the value on the table.
As last step, set the value to the Max and you are done..
Enjoy!
I'm having an issue that i can't seem to solve on my own:
I have a model that has two tables.
Fruit_data_Table
Date
Fruit_id
Fruit_category
Fruit_scheduled_picking_time
Fruit_real_picking_time
Fruit_picked_within_1min = 1 or 0
Fruit_picked_within_5min = 1 or 0
etc etc
On every given day i have 700 different fruit entries on my fruit_data_table.
I created a Calendar_Table using a classic :
Calendar_Table= CALENDAR(MIN(Fruit_data_Table[Date]);MAX(Fruit_data_Table[Date]))
And then i needed combined averaged values for any given day, including rolling averages, so inside my Calendar_Table i added some calculated columns for every dates such as :
Fruit_on_time_1_min_pick=
VAR this_date = Calendar_Table[Date]
RETURN CALCULATE(
SUM(Fruit_data_Table[Fruit_picked_within_1min ])/COUNT(Fruit_data_Table[Fruit_picked_within_1min ]);Fruit_data_Table[Date] = this_date)
Or a rolling average :
Fruit_on_time_1_min_pick_7day_average=
VAR this_date = Calendar_Table[Date]
RETURN CALCULATE(
SUM(Fruit_data_Table[Fruit_on_time_1_min_pick])/COUNT(Fruit_data_Table[Fruit_on_time_1_min_pick]);
DATESBETWEEN(Calendar_Table[Date];DATEADD(LASTDATE(Calendar_Table[Date]);-6;DAY);LASTDATE(Calendar_Table[Date])))
Which mean i ahve something like
Calendar_Table
Date
Fruit_on_time_1_min_pick (%)
Fruit_on_time_1_min_pick_7day_average (%)
etc etc
This all seems to work pretty well and i have my daily rate of fruit pciked on time and rolling averages.
The problem is that then i can't use my slicer to sort by fruit_category, or by time_of_day for example... any idea how i can get back to those slicers ?
(The PowerBi rolling average function don't seem to work at all for me, even though my Calendar_Table is a PowerBi generated Date Table...)
Thank you very much !
PS: real code is about train numbers is a major french train station... not really about fruits :)
I have data in tableau like below
day employee expense_reason expense
2/24/2018 abc car mileage $5
2/24/2018 xyz car mileage $5
2/24/2018 xyz car rent $8
2/24/2018 xyz car rent $9
I want to find occasions when on a same day, single employee claims both expenses. I am producing below view in Tableau using
day and employee as rows
expense reason as column
and sum(number of rows) as Text
i am getting grand total using analysis>>totals>>show row totals
instead of getting row totals, how could i get count of non zero values in a row
expense_reason
day employee car mileage car rent grand total
2/24/2018 abc 1 1
2/24/2018 xyz 1 2 3
update 1
i tried below as per one of the answers but it is not giving output that i want
First of all you should solve the No-Data part since there's no data for the combo abc-rent.
You can achieve this using the lookup function, forcing a fake lookup using 0 as parameter.
Something like this:
LOOKUP(SUM([Something]),0)
Then you can use ZN function to force a zero for a null value, which is different from No Data.
That being said, you should be able to get something like this:
Here's the Calculated field:
zn(LOOKUP(max({ FIXED [day],[employee],[reason] : COUNT([reason])}),0))
EDIT
If you want to have grand totals, i think this should be the better solution:
And the Calculated Field is a pure Count nested in a lookup function as said before:
zn(LOOKUP(COUNT([expense]),0))