Tableau calculated field-formula - tableau-api

I am trying to create a simple formula for calculation in table .
This is the table structure
EXPERIENCE PLATFORM REVENUE
PC WEBSITE 100
MOBILE ANDROID 20
MOBILE IPAD 10
MOBILE IPHONE 20
My calculation is trying to find the share :
Calc1: Share of site= sum of revenue from mobile / sum of revenue (mobile+PC)
Calc2: share of platform= sum of revenue from apps/revenue from mobile
Can someone highlight how I can create a formula , I am very new to tableau.
Thanks

For Calc1, try a calculated field like:
sum(iif([Experience]='MOBILE',[Revenue],0))/sum([Revenue])
Calc2 uses similar logic:
sum(iif([Platform]='ANDROID',[Revenue],0))/sum(iif([Experience]='MOBILE',[Revenue],0))
You should also be able to get what you need using the Tableau built in table calculations, by dragging in what you need and adjusting filters as necessary.

Related

Power BI: Filter sales table with multiple locations on respective start dates from different table

I've tried to find a similiar thread on this, but have not been able to do so. Im pretty new to Power BI, so i might not know what im looking for. I could really use some advise.
I have a sales table ('SalesTable') that contains all the sales from different store locations. The table includes all the sales from each store beginning in january 2021, but the stores was incorporated on different dates in 2021, and so i need to be able to make a filter to only return the sales for each store from when the stores was incorporated respectivaly.
Simplified, the tables looks like this:
'SalesTable'
'SalesTable'
'Stores'
'Stores'
The two tables are joined on storeID. SalesTable is also connected to a dax-created Calender table. The stores table is not connected to the calender table (Maybe it should??).
I need to be able to filter the report so that it only returns sales dated on or after the respective incorporateddate.
Like this:
'Desired output'
I am not sure whats the optimal way to go about this. If i should make a calculated table of the SalesTable, or if a measure is sufficient to filter the report. Any suggestions, tips or solutions would be highly appreciated :)
You can use this measure:
sumIncorp =
var __maxIncorp = CALCULATE(max(inc[IncorporatedDate]), FILTER(inc, inc[StoreID] = SELECTEDVALUE(IncSale[StoreID])))
return
CALCULATE(SUM(IncSale[Amount]), FILTER(IncSale, IncSale[Date] >= __maxIncorp))

How to write the queries in power bi

I am using Power BI in my current project for making charts. My data source is Azure SQL database.
I would like a table chart to display today and yesterday data only, for which i used advanced filtering by setting the filter to today and yesterday dates. However, I want to be able to open my report tomorrow and see charts use data from tomorrow and today respectively.
With advanced filtering the charts appear static, not dynamic.
It would be good if someone could explain how to write queries in Power BI on my tables.
You could either
1) modify your sql query to only return today and yesterday data
or
2) add a calculated boolean column, something along the lines of
"IsCurrent = IF(AND(DATEVALUE(Table1[Date])<=TODAY() , 1.0*(DATEVALUE(Table1[Date])-TODAY())<=2),True,False)"
Then filter by IsCurrent.
Using the SDK you can apply filter(s) dynamically to the report. This allows you to simulate the user filtering the report data to the current day and yesterday.
Your client app would compute the correct filter data values and apply it to the report. Using something like report.setFilters(filters)
See this related question for more information about filters:
Power BI Embed URL-multiple filters

Tableau Pie-Chart with Measures

I have data with many measures values for each SiteID, i.e.
Total Windows Total Mac Total Online Total Offline Total Computers SiteID
I have been googling how to create pie chart in Tableau, but these tutorials assume I have data that looks like
OS Status SiteID
What I am ultimately trying to do is create a pie chart of online vs offline users and use actions from other data points to filter that chart.
I just need to know how to create pie-chart and from there I can create action.
If I understand your question correctly, it sounds like you want to make a pie chart showing online users vs. offline users, and be able to filter it by SiteID.
You could do this by:
Go to Marks and select Pie.
Drag [Measure Names] into Color.
Drag [Measure Values] into Angle.
Remove all pills except for [Total Online] and [Total Offline] from the Measure Values card.
Then you can create a SiteID filter by creating a quick filter, dragging SiteID to the filter card, or using an action from a dashboard.
Sounds like you need to reshape your data. Can you use SQL to do so?

How do I calculate market share in Tableau while maintaining a fixed base?

I am looking for a way to calculate market share for a given country but need the base to remain constant. It's my understanding that I cannot utilize the table calculation for "% of total" because obviously it will always be 100%.
Here is the scenario in detail:
I'm looking to add the market share % detail to my dashboard. I have 36 countries as well as seven groups of countries I'd like the user to be able to select. There is a map as well as a drop-down parameter to select these countries/groups. The goal is to have one percentage displayed on the dashboard based on the user's selection. The base will always be the 36 country total sales.
Am I overlooking something obvious? Has anyone had a similar dilemma?

AVERAGEIF Excel function into Google Spreadsheet

Alright, I was able to get it to get this formula working within excel:
=AVERAGEIFS($B$8:$B$88,$B$3:$B$83,"Coupons",$B$4:$B$84,"Holiday")
The formula averages the Open Rates for specific data-sets depending on their Type and Sub Type.
If B3 equals Coupons and B4 equals Holiday then paste the Average of the Open Rates for all the campaigns that contain the first two attributes into another spreadsheet.
As we all know, Google Spreadsheet does not recognize AVERAGEIF. I have been attempting to make a hybrid with the Formula Array function coupled with either FILTER or AVERAGE to no avail. Any help would be much appreciated. Thanks.
Image of spreadsheet
Try this version
=arrayformula(AVERAGE(IF($B$3:$B$83="Coupons",IF($B$4:$B$84="Holiday",$B$8:$B$88))))
The new version of Google Docs has an averageif function