0

Formula for measure filtered by a dimension

I have the fact and dimension tables below:

SourceType dimension

·         SourceType 1

·         SourceType 2

·         SourceType 3

·         SourceType 4

Event fact

·         Count of events

I would like to

1)      create a formula which calculates the count of events for all SourceTypes except for SourceType 3. 

2)      create a pivot table which uses the above created formula to display the count of events by SourceType, excluding SourceType 3

 

 

Count of events no sourcetype 3

SourceType 1

3

SourceType 2

4

SourceType 4

6

 

3)      use the formula with any other connected dimension

4)   if any other SourceTypes are added in the future, they would be included (in other words, need to use Except)

 

I created a list in Formulate as

{Except(AllMembers([SourceTypesTable].[SourceTypes]),[SourceTypesTable].[SourceTypes].[SourceType 3])}

 

And then used this list in another formula

Aggregate({[SourceTypeTable].[SourceType].*[272cf8c2-2350-4c51-bcd0-730258cbef37]},([measures].[EventsTable Events]))

 

This achieved #1 and #3 but not #2.

Thanks for the help.

3 replies

null
    • Brendan_Conway
    • 19 hrs ago
    • Reported - view

    Hi Michael, 

    Sounds like you're pretty close so far. Would you be able to provide a screenshot of what you have in Discover, so I can see what you're missing?

    My initial thought is that you don't need to Aggregate in your formula. If all you're trying to do is have a scalable list that removes a single element (SourceType3), then your list should do the heavy lifting and you can drop in your measure for the counts.

      • Michael_Connelly
      • 4 hrs ago
      • Reported - view

       Thanks.  Here's a screenshot from Discovery as well as a screenshot of the same thing in PowerBI which is what I'm trying to achieve.

      In Pyramid, the formula (filtered measure) doesn't take the row context into account, thus produces the same output for all members (the total 897,687)

       

      In PowerBI the formula for the filtered measure is

      Filtered Measure = CALCULATE(COUNT(EventsTable[EventKey]),SourceTypeTable[SourceTypeKey]<>1)
      

      When this is dropped into a matrix, the filtered measure first takes the row context into account and then applies the filter in the formula.  The output is the same as "raw" measure for each member except for the member that is excluded.

       

      • imbarmarinescubar_pyram
      • 32 min ago
      • Reported - view

      Hi  

      You can write the same kind of expression in Pyramid:

      count(if([SourceTypeTable].[SourceTypeKey]=1, null, [EventsTable].[EventKey]))

Content aside

  • 32 min agoLast active
  • 3Replies
  • 31Views
  • 4 Following