Showing posts with label stores. Show all posts
Showing posts with label stores. Show all posts

Thursday, March 22, 2012

Distinct count problem

Hi,

I'm trying to create a measure (distinct count) for counting the number of stores which sell product. I used to fact table to count store_key but I've just realized this measure returns a count including stores which do not sell the product.

Daily Sales fact : store_key, net sales dollars .....

How should I define the calc in this case? I'm thinking conditional statements but not clear yet.

Please give me some comments. Thanks.

We do something similar - a count of invoices that have a coupon applied to them. There are two ways (that I know of) to do this:

1) at the fact level. Have a measure in your fact table that contains a 1 or 0 for each store that sells the product. Not a very efficient way, but it will get the job done. Do a sum on this measure. Depending on how you want to count your products, you could have a measure group that is store_key, product_key, sells_product (int). This will work, but definitely not efficient.

2) The way we do it is to make the item you are measuring an attribute of the dimension itself. In our case we have an invoice dimension which contains a "has_coupon" attribute. As part of the ETL we determine if the value of has_coupon shoud be "Yes" or "No". You then can query according to the values of this attribute. We then can do [Invoice].[Has Coupon].Children.Count, or any other derivation of it.

I would recommend option #2, but it all depends on your situation. If anyone else knows of other ways to model, I'm curious too.

Good luck,

John Hennesey

|||Not totally clear, but is it counting a NULL value when you don't want it to?

Just create another fact table in the DSV based off of the fact table where the key is not null:

select *
from fact
where
key is not null

And create the DISTINCT COUNT measure based of this new new table.
|||

thanks.

it's easy and it works fine Smile

sql

distinct count

Hi

I have a table which stores the shift information for employees. The table contains 10 columns as Employeename,Employeeno,month,year,shifttimings etc. If an employee works a day in a particular shift, then a row will be inserted in to the above table for that employee.

Now at the end of the month i wanted to calculate the shift details for each employee for a particular month of a given year like employeename,employeeno, noofdays(countof shiftdays).

Can some body help?

Thanks in Advance!

Santhosh

Select

Employee.EmployeeName,

Employee.EmployeeNo,
|||

Select EmployeeName, EmployeeNo, Count(*) As NoOfDays

From EmployeeShift

Where Month = @.Month And Year = @.Year

Group By EmployeeName, EmployeeNo

|||

You could create a view as

Select EmployeeName, EmployeeNo, Month, Year, Count(*) As NoOfDays

From EmployeeShift

Group By EmployeeName, EmployeeNo, Month, Year

and apply Where to it...

sql

Wednesday, March 21, 2012

Displying rtf database field properly formatted

I am a simple user- I have a SQL Server database that stores a particular field as rtf, including all of the formatting characters in addition to the actual user-entered text.

I use the report wizard to easily build reports, but this particular field outputs all of the gobbldygook but I just want the user-entered text.

Crystal Reports easily translates rtf- why can't Microsoft easily translate their own format? Any help would be appreciated.

Hi kc,

This is a feature we are looking at for later releases. We want something like this too.

sql

Monday, March 19, 2012

Displaying selected rows from a Fact table

I have a fact table which stores data ( customer name, document type, editing start time, editing end time, editor, revision id etc) for each revision of a document.

While displaying data however i need to take into account only the last revision of each document.

What is the best way of doing this? Do I need to create a separate dimension table with the document id and max revision id as fields or is there a better way of doing it?

One idea would be to mark Revision dimension as of type Time, and use semiadditive measure LastNonEmptyChild - this will show data for the last revision only.|||

I also need to create calculated members based on the lastnonemptychild. How do I do that?

Eg: for last nonemptychild ie. last revision I need to count the number of records that are of type 'S'

I also need to calculate percentage of records of last revision that are greater than target time and less than target time.....

|||This is very easy to do. Assuming you have attribute called RecordType, you can create calculated measure with|||

In the previous post you mentioned mark Revision dimension of type time. How do I do tht?

Does this also mean tht I should hv a separate dimension for revisions with attributes being documentid and revid and the hierarchy being documentid -> revid ? For the lastnonemptychild aggregation to work? That would mean tht the dimension table would contain as many records as the fact table isnt it?

|||

You don't need to change anything about your revision dimension. I imagine, that it has key attribute having values of 1,2,3,... up to whatever largest revision you think you will have in few years. I don't see the reason to include document id into this dimension - different documents can have same revision - there is no problem with it.

In the dimension editor, simply go to the properties of dimension, and choose the value Time for the property Type.

|||After changing revision dimension's property type to time, how do I use the semiadditive measure last child to sum only the records with the last revision id for the Measure InTAT ( where InTAT is either 1 or 0) ?|||You need to change Aggregation Function for this measure from Sum to LastNonEmptyChild.|||For a calculated measure how do I use the LastNonempty measure and get the sum of records with last revid?|||It is not a calculated measure. It is a real measure. Marking it as LastNonEmpty will cause returning sum of records with last revid.|||I have some calculated measures called TAT Factor, Half TAT etc for which too I need to be able to sum on the lastrevid. How do I do that?|||Make them a real measures, and move whatever expressions you use for them to the Leaves(Revision) inside MDX Script.|||I am new to analysis services. Could you explain what you mean by moving the expressions to the leaves? Should I make calculated columns in the view?

Displaying selected rows from a Fact table

I have a fact table which stores data ( customer name, document type, editing start time, editing end time, editor, revision id etc) for each revision of a document.

While displaying data however i need to take into account only the last revision of each document.

What is the best way of doing this? Do I need to create a separate dimension table with the document id and max revision id as fields or is there a better way of doing it?

One idea would be to mark Revision dimension as of type Time, and use semiadditive measure LastNonEmptyChild - this will show data for the last revision only.|||

I also need to create calculated members based on the lastnonemptychild. How do I do that?

Eg: for last nonemptychild ie. last revision I need to count the number of records that are of type 'S'

I also need to calculate percentage of records of last revision that are greater than target time and less than target time.....

|||This is very easy to do. Assuming you have attribute called RecordType, you can create calculated measure with|||

In the previous post you mentioned mark Revision dimension of type time. How do I do tht?

Does this also mean tht I should hv a separate dimension for revisions with attributes being documentid and revid and the hierarchy being documentid -> revid ? For the lastnonemptychild aggregation to work? That would mean tht the dimension table would contain as many records as the fact table isnt it?

|||

You don't need to change anything about your revision dimension. I imagine, that it has key attribute having values of 1,2,3,... up to whatever largest revision you think you will have in few years. I don't see the reason to include document id into this dimension - different documents can have same revision - there is no problem with it.

In the dimension editor, simply go to the properties of dimension, and choose the value Time for the property Type.

|||After changing revision dimension's property type to time, how do I use the semiadditive measure last child to sum only the records with the last revision id for the Measure InTAT ( where InTAT is either 1 or 0) ?|||You need to change Aggregation Function for this measure from Sum to LastNonEmptyChild.|||For a calculated measure how do I use the LastNonempty measure and get the sum of records with last revid?|||It is not a calculated measure. It is a real measure. Marking it as LastNonEmpty will cause returning sum of records with last revid.|||I have some calculated measures called TAT Factor, Half TAT etc for which too I need to be able to sum on the lastrevid. How do I do that?|||Make them a real measures, and move whatever expressions you use for them to the Leaves(Revision) inside MDX Script.|||I am new to analysis services. Could you explain what you mean by moving the expressions to the leaves? Should I make calculated columns in the view?

Sunday, February 19, 2012

Display percentage % field and format

Hi,
In the group footer I want to show:
Total store with ABC systems is: 33% of Total stores
33% is a calculated field.
The expression for this is:
"Total store with ABC systems is: " & =Fields!A1.Value/Fields!B1.Value
& " of Total stores"
I merged 3 cells and put this expression is in one text box, this
output would be:
summary 0.33333333333 of Total stores
So I split the cell into three:
in first cell: Total store with ABC systems is:
in second cell: =Fields!A1.Value/Fields!B1.Value (format set to p0)
in third cell: of Total stores
but the width of percentage field is limited by the table column, so
the 33% would be either too far from the first cell or from the third
cell.
What can I do to concatenate them into one line without too much
space?
Thanks in advance.
DanniTry this: ="Percentage is " &
Format((Fields!A1.Value/Fields!B1.Value)/100.0, "p") & " of Total stores"
--
Ravi Mumulla (Microsoft)
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Danni Liao" <danniliao@.yahoo.com> wrote in message
news:9d716b4a.0408231056.2d1b695e@.posting.google.com...
> Hi,
> In the group footer I want to show:
> Total store with ABC systems is: 33% of Total stores
> 33% is a calculated field.
> The expression for this is:
> "Total store with ABC systems is: " & =Fields!A1.Value/Fields!B1.Value
> & " of Total stores"
> I merged 3 cells and put this expression is in one text box, this
> output would be:
> summary 0.33333333333 of Total stores
> So I split the cell into three:
> in first cell: Total store with ABC systems is:
> in second cell: =Fields!A1.Value/Fields!B1.Value (format set to p0)
> in third cell: of Total stores
> but the width of percentage field is limited by the table column, so
> the 33% would be either too far from the first cell or from the third
> cell.
> What can I do to concatenate them into one line without too much
> space?
>
> Thanks in advance.
> Danni|||Or you could leave out the /100.0 and go to
Properties => Format => enter p2 for percent with a matissa of 2 places.
Bryan
"Ravi Mumulla (Microsoft)" wrote:
> Try this: ="Percentage is " &
> Format((Fields!A1.Value/Fields!B1.Value)/100.0, "p") & " of Total stores"
> --
> Ravi Mumulla (Microsoft)
> SQL Server Reporting Services
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "Danni Liao" <danniliao@.yahoo.com> wrote in message
> news:9d716b4a.0408231056.2d1b695e@.posting.google.com...
> > Hi,
> >
> > In the group footer I want to show:
> >
> > Total store with ABC systems is: 33% of Total stores
> >
> > 33% is a calculated field.
> >
> > The expression for this is:
> > "Total store with ABC systems is: " & =Fields!A1.Value/Fields!B1.Value
> > & " of Total stores"
> > I merged 3 cells and put this expression is in one text box, this
> > output would be:
> > summary 0.33333333333 of Total stores
> >
> > So I split the cell into three:
> > in first cell: Total store with ABC systems is:
> >
> > in second cell: =Fields!A1.Value/Fields!B1.Value (format set to p0)
> >
> > in third cell: of Total stores
> >
> > but the width of percentage field is limited by the table column, so
> > the 33% would be either too far from the first cell or from the third
> > cell.
> >
> > What can I do to concatenate them into one line without too much
> > space?
> >
> >
> > Thanks in advance.
> > Danni
>
>

Display of Data category wise

Hi,

I have a requirement where I need to display the items category wise

I have 3 tables,

one stores category_id, parent_id and category_name

second table stored item_id,item_name and proce

3rd table stores category_id and item_id

I need to display the values like this

Category name, Item name

with first parent category ans ites items should be displayed and next sub category and its item

By category table with contain 2 levels of sub category

i.e Category1

Category11

Category111

any help with the query would be much appreciated,

I wrote the query something like this...

select c.category_name,parent_id,item_namefrom category c,items i,Category_item ciwhere

ci.item_id=i.item_idand c.category_id=ci.category_idorderby parent_id, category_name

But it will display all parent category items then the sub category items I want to display like thiscategory1 items1category11 item11category1 item12category11 item111category11 item112 category2 item2

Thanks

What you want is called "grouping".

Seehttp://www.google.com/search?q=gridview+grouping

Jos

|||

Please check the below mentioned URL:

http://vyaskn.tripod.com/hierarchies_in_sql_server_databases.htm

Tuesday, February 14, 2012

Display empty rows

I am creating some reports with crystal reports 8.5

I made crosstabs listing the sales of certain products by store and month.

The stores are listed in the rows, products and months are in the columns. In the complete yearly reports everything is fine, because there are no empty rows.

When i create subreports for just a certain month or product, there might be empty rows, like, there might have been no sales of that particular product, in that store in that month. Instead of just displaying a row with the store name and Zero value, it just doesn`t show the row at all.

I need those empty rows to show and display zero values. The option "suppress empty rows" is not checked.

Any ideas ?

Example
...............January 2007
...............Product 1
Store1......0 <- this row is not displayed
Store2......6
Store3......24You'll need an outer join somewhere, rather than an inner join - read the help on join types, or describe your current tables and joins.|||I am just beginning in crystal but I did have the same issue but my training yesterday was about table joints.
You have to have your primary table as your "source" table where you have most of your data. When you link your secondary table, go to link options and you need to have the linking as "left join or outter join ...not Equal". Even though you have no value on that one record, it will show it with an empty cell or box but you will see everything else from that record. I still wouldn't know how to display the zero.