Show Total In SSRS Chart

Question!

I am creating a line chart from an Analysis Services cube, with a date category, a count data field, and a status series. Here's a screenshot to explain:

picasaweb.google.com/lh/photo/fP16V4sB18O1xSTrdDV-_A?authkey=Gv1sRgCLHRmcjwtI2mzAE

I want to add the blue total line, which sums all the statuses together.

I don't want to add a "Total" member to the Status dimension, because that wouldn't make sense. I've tried adding another data field and scoping it to sum everything, but I can't figure out how to make the series field only apply to a single data field�so this ends up duplicating all the statuses and getting 8 lines instead of 5.

This should be possible... I don't want to resort to writing SQL against the underlying database.



Answers

Alright so I figured out a reasonable solution in MDX. I think it would be better solved in SSRS, but I haven't figured that out yet.

The trick is to add the [Total] member to the result set, instead of adding it to the actual Dimension. Simplified MDX is here:

WITH 
MEMBER [Execution Status].[Execution Status].[Total] AS 
    AGGREGATE([Execution Status].[Execution Status].[Pass].Siblings)

SELECT 
    {[Measures].[Count]} ON COLUMNS,
    {[Execution Status].[Execution Status].Children,
     [Execution Status].[Execution Status].[Total] } ON ROWS

FROM [CUBE]

This defines an additional member for Total which aggregates all the Statuses. Then all the Status members as well as the Total are returned. SSRS doesn't care--it still groups by the new set.

I did have some issues with getting the Aggregation to work, which is why I'm using [Pass].Siblings. [Execution Status].Children always returned (null), and [Execution Status].[All] returned 2x the correct answer, presumably because of the [All] member. I could manually enumerate all the statuses as well. Still not sure what the issue there is...



Just use std::random_shuffle found in <algorithm>, like this:

std::random_shuffle(deck, deck + deckSize);

and your deck with be shuffled.

By : user83255


People are complaining that you're not using containers and not declaring the size of your array. Don't worry about that, that's not the problem. Someone also said you're going past array boundaries, which you aren't. It's okay to have arrays with size not declared. It's also okay to have an array of pointers to Card. But the thing I don't get is why it crashes. Here's some sample code I wrote, based on your code:

#include <stdio.h>
#include <stdlib.h>
#define DECK_SIZE 24
void shuffle(int deck[]) {
    int n = DECK_SIZE, t;
    while (n > 1) {
        long k = lrand48() % DECK_SIZE;
        n--;
        t = deck[n];
        deck[n] = deck[k];
        deck[k] = t;
    }
}
int main(int argc, char **argv) {
    int deck[DECK_SIZE], i;
    for (i = 0; i < DECK_SIZE; ++i)
        deck[i] = i + 1;
    shuffle(deck);
    for (i = 0; i < DECK_SIZE; ++i)
        printf("%i\n", deck[i]);
    return 0;
}

Run it, it works perfectly fine. That means there is something else going on. Try printing the value of all the cards in your deck before you call shuffle to see if it segfaults there too, I suspect it would.

However, there IS an error in your code. Your function does not shuffle correctly. The correct way to shuffle is not to swap each card with a card selected from the entire deck, but to swap each card at position N with an card selected from the range 0..N. If you swapped each card with a random card you get N^N possible outcomes, some of which overlap if you swap a card back to its original place. With a 3 card deck it's apparent that this is wrong because you will end up with 27 different shuffles, some of which are the same, even though there are 3!=6 permutations of 3 cards. The problem is that since 6 is not a factor of 27, some permutations are more likely than others. To avoid this, try doing it this way:

void shuffle_correctly(int deck[]) {
    int i, t, k;
    for (i = 2; i < DECK_SIZE; ++i) {
        k = lrand48() % i;
        t = deck[i-1];
        deck[i-1] = deck[k];
        deck[k] = t;
    }
}


This video can help you solving your question :)
By: admin