简体   繁体   中英

Calculated member for Count of False values within group

I want to be able to get a count of the "IsDefault" column per FundTyoeCode whern IsDefault is "False"

SELECT { [Measures].[Total Funds]} ON COLUMNS, 
Non Empty CrossJoin ({
[ExpenditureLineItem].[ProgLookup].[ProgLookup].&[C81C0001]},
{
[Fund].[FundTypeCode].[FundTypeCode].allmembers*
[Fund].[Description].[Description].Allmembers*
[Fund].[IsDefault].[IsDefault].Allmembers
}
)On Rows
FROM   [Model]

Here is what the query results

Program Fund CODE   Fund Name                  Is Default   Total Funds
C81C0001    1       General Funds              TRUE         $26,564,116.00 
C81C0001    3       Cigarette Restitution Fund FALSE        $600,000.00 
C81C0001    3       Special Funds              TRUE         $5,822,569.00 
C81C0001    9       Reimbursable Funds         TRUE         $8,889,780.00 

So per this example the calculated member column should give me a count of 1 for the Fund Code 3

I've been playing with the Calculated member

WITH MEMBER [CountFalse] as count( { [Fund].[IsDefault].[IsDefault].[False]*[Fund].[FundTypeCode].[FundTypeCode]}) But its showing incorrect results.( all FundTypeCodes, not just the ones sliced by my query)

Try:

WITH 
MEMBER [CountFalse] as 
SUM(
    existing [Fund].[FundTypeCode].[FundTypeCode].Members,
    IIF(
        ([Fund].[IsDefault].[False],[Measures].[Total Funds]) > 0,
        1,
        NULL
    )
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM