SSAS Tabular create table from another table with unique column - ssas

I have ssas table called orders. I want to extract distinct EmployeeID from the table to create Emp_ID table. when I use
=SUMMARIZE(Orders,Orders[EmployeeID])
it worked but it add a blank row
Current OUTPUT
Expected OUTPUT to exclude the blank using DAX

Got it
=FILTER(
SUMMARIZE(Orders,Orders[EmployeeID]),
Orders[EmployeeID]<> BLANK()
)

Related

Power BI Report Builder Dynamic Tables based on column

I have a table that contains the columns name age and Dept. I am new to report builder and wanted to know if there is a way possible to create dynamic tables based on distinct departments in the base table
Below is the base data
and this is how I want this to be represented in SSRS dynamically based on distinct items in the Dept. column
Thanks in advance!
Just add a Row Group to your table that grouped by Dept.
If you click the existing table you should see one of more row groups in the groups panel below the main design window. There might be just a single "Details" row group. Right click the row group and add a parent group, select Dept as the column to group by and that's it.
Figured this out.
Can use a list and add the desired table in there and then add in a group for the column required in the Group properties of the row

Adding a column to existing table in access without using any relationship

I am working on a project in ACCESS 2010 that requires me to give a rank to 30000 products based on their sales. I have tried using a query to do the ranking and it takes a long time. (Please find codes at Making the ranking query efficient)
I figured out that instead, I can just sort the table based on the Sales column and add a field with numbers 1 to 30000.
So is there a way to add such a column, i.e. a column without any relationship to the existing table.
Add a field to the actual table? If that's the case, make a table and run this query:
ALTER TABLE yourTableName
ADD COLUMN yourColumnName AUTOINCREMENT(1, 1)

How to join a column from another table to a new table you wish to display

I am currently working on a database where I am trying to find all the transactional type tables (where the table name does not start with _Result or _ History) in the database and then display how many times each table is used in a calculation for the database model.
The purpose of finding out this is to determine the most important tables in the calculation, so that these certain tables will have a priority when updating statistics.
There are currently two tables I am working with.
1) The first table called tmpCalcSources shows the name for all the source tables in the database (Column called 'Source') along with the Calculation ID (Column called 'CalculationID') associated with it
2) The second table called tmpCalcSourceRows shows the source table name (Column called 'TableName') as well as the amount of rows associated with each source table (Column called 'RowNum')
I currently have this query:
SELECT Source,
COUNT(CalculationID) AS NumberOfUses
FROM tmpCalcSources
WHERE Source not like '%_Result%'
GROUP BY Source
ORDER BY NumberOfUses DESC;
The above query provides me with the following table:
plPeriods 292
plMeasures 10
Time 43
etc...
I am now trying to add one more thing to the above table. I want it to also show the number of rows contained in each table (so a another column). I would like to take the column 'RowNum' from tmpCalcSourceRows table and be able to display that in the table shown above.
Is this what you're looking for:
select
Source
, NumberOfUses
, numberofrows
from (
SELECT Source,COUNT(CalculationID) AS NumberOfUses
FROM tmpCalcSources
WHERE Source not like '%_Result%'
GROUP BY Source
) tableUses
join numRowsTable on numRowsTable.TableName=tableUses.Source
ORDER BY NumberOfUses DESC;

Get fields from one column to another in Access

Below i have a table where i need to get fields from one column to three columns.
This is how i would like the data to end up
Column1
Music
Column2
com.sec.android.app.music
Column3
com.sec.android.app.music.MusicActionTabActivity
Give the table a numeric autonumber id
Remove the rows with no data with a select where blank spaces or null
Find records with no point in the content with a select
Use the previous query as a source and use the id to find the id + 1 to find the next record and do the same with + 2 to find the second row
Build a table to hold the new structure and use the query as a source to insert the new created data in the new table with the 3 columns structure.
This is an example using sql server
Test table design
Data in table
Query
Look at the query from the inside. The first query inside clean the null records. Then the second query find the records with out point. This records are the reference to find the related two records. Then the id of the records with out point are used to make a query in the select adding 1 for the next record and then other query adding 2 to find the other record. Now you only need to create a table to insert this data, using this query as the source.

Updating one SQL table based on data in another table

I am running Microsoft SQL Server 2008 R2, and pulling information from two tables to create one new table.
Table A has leads with a unique lead number and other information.
Table B has sales with a unique sales number, and the lead number associated with it.
Data from both tables are pulled into temp tables in SQL Server so I can change and update whatever I need, and the output of this will go into a new table.
One lead from Table A can have multiple sales associated with it in table B.
I want to update the Number of Sales column in Table A (Leads) based on how many times that lead number appears in Table B (sales). So if Table B (sales) has a lead number tied to seven (7) sales, the Number of Sales column in Table A (leads) will be updated to 7.
I have tried a few variations using the COUNT function but with no success. Any help would be appreciated.
This should work for you assuming the field name is leadNo:
update tablea
set sales = (select count(*)
from tableb
where tableb.leadNo = tablea.leadNo)
SQL Fiddle Demo