Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
I want to achieve the following logic
I have achieved the GREEN part, but struggling with the RED part.
My Dax is as follows -
=IF(SUM ( 'MasterTbl'[Sett] ) = 1,
SUMX (
(IF (
SUM ( 'MasterTbl'[Sett] ) = 0,
CALCULATE (
SUM ( 'MasterTbl'[Total number of beneficiaries] ),
ALLEXCEPT ( MasterTbl, 'MasterTbl'[Activities and Indicators.Activities] )
) )),
IF
(
VAR _categoryfirst =
CALCULATETABLE (
ADDCOLUMNS (
VALUES ( 'MasterTbl'[List of refugee settlements-Iran.settlements name] ),
"MaxValue",
CALCULATE (
MAX ( 'MasterTbl'[Total number of beneficiaries] ),
ALL ( 'MasterTbl'[Total number of beneficiaries] )
)
),
ALL ( 'MasterTbl'[Total number of beneficiaries] )
)
RETURN
CALCULATE (
MAX ( 'MasterTbl'[Total number of beneficiaries] ),
KEEPFILTERS (
TREATAS (
_categoryfirst,
'MasterTbl'[List of refugee settlements-Iran.settlements name],
'MasterTbl'[Total number of beneficiaries]
)) )) >= SUM('Settlement name'[population]), SUM('Settlement name'[population])),
(
VAR _categoryfirst =
CALCULATETABLE (
ADDCOLUMNS (
VALUES ( 'MasterTbl'[List of refugee settlements-Iran.settlements name] ),
"MaxValue",
CALCULATE (
MAX ( 'MasterTbl'[Total number of beneficiaries] ),
ALL ( 'MasterTbl'[Total number of beneficiaries] )
)
),
ALL ( 'MasterTbl'[Total number of beneficiaries] )
)
RETURN
CALCULATE (
MAX ( 'MasterTbl'[Total number of beneficiaries] ),
KEEPFILTERS (
TREATAS (
_categoryfirst,
'MasterTbl'[List of refugee settlements-Iran.settlements name],
'MasterTbl'[Total number of beneficiaries]
) ) ) ) ),
( IF (
SUM ( 'MasterTbl'[Sett] ) = 0,
CALCULATE (
SUM ( 'MasterTbl'[Total number of beneficiaries] ),
ALLEXCEPT ( MasterTbl, 'MasterTbl'[Activities and Indicators.Activities] )
),
IF
(
(
VAR _categoryfirst =
CALCULATETABLE (
ADDCOLUMNS (
VALUES ( 'MasterTbl'[List of refugee settlements-Iran.settlements name] ),
"MaxValue",
CALCULATE (
MAX ( 'MasterTbl'[Total number of beneficiaries] ),
ALL ( 'MasterTbl'[Total number of beneficiaries] )
)
),
ALL ( 'MasterTbl'[Total number of beneficiaries] )
)
RETURN
CALCULATE (
MAX ( 'MasterTbl'[Total number of beneficiaries] ),
KEEPFILTERS (
TREATAS (
_categoryfirst,
'MasterTbl'[List of refugee settlements-Iran.settlements name],
'MasterTbl'[Total number of beneficiaries]
)
)
)
) >= SUM('Settlement name'[population]), SUM('Settlement name'[population]),
(
VAR _categoryfirst =
CALCULATETABLE (
ADDCOLUMNS (
VALUES ( 'MasterTbl'[List of refugee settlements-Iran.settlements name] ),
"MaxValue",
CALCULATE (
MAX ( 'MasterTbl'[Total number of beneficiaries] ),
ALL ( 'MasterTbl'[Total number of beneficiaries] )
)
),
ALL ( 'MasterTbl'[Total number of beneficiaries] )
)
RETURN
CALCULATE (
MAX ( 'MasterTbl'[Total number of beneficiaries] ),
KEEPFILTERS (
TREATAS (
_categoryfirst,
'MasterTbl'[List of refugee settlements-Iran.settlements name],
'MasterTbl'[Total number of beneficiaries]
) ) ) ) ) )))
Hi @zahirr ,
I can't understand what you mean, please share your sample data and expected output.
Also, I formatted your formula but not sure if it is consistent with yours, please check my sample data and output.
Measure =
VAR _categoryfirst =
CALCULATETABLE (
ADDCOLUMNS (
VALUES ( 'MasterTbl'[List of refugee settlements-Iran.settlements name] ),
"MaxValue",
CALCULATE (
MAX ( 'MasterTbl'[Total number of beneficiaries] ),
ALL ( 'MasterTbl'[Total number of beneficiaries] )
)
),
ALL ( 'MasterTbl'[Total number of beneficiaries] )
)
VAR max_beneficiary =
CALCULATE (
MAX ( 'MasterTbl'[Total number of beneficiaries] ),
KEEPFILTERS (
TREATAS (
_categoryfirst,
'MasterTbl'[List of refugee settlements-Iran.settlements name],
'MasterTbl'[Total number of beneficiaries]
)
)
)
VAR Sum_ =
CALCULATE (
SUM ( 'MasterTbl'[Total number of beneficiaries] ),
ALLEXCEPT ( MasterTbl, 'MasterTbl'[Activities and Indicators.Activities] )
)
RETURN
IF (
SUM ( 'MasterTbl'[Sett] ) = 1,
SUM ( 'MasterTbl'[Total number of beneficiaries] ),
IF (
SUM ( 'MasterTbl'[Sett] ) = 0,
MIN ( max_beneficiary, SUM ( 'Settlement name'[population] ) )
)
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
12 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
24 | |
19 | |
14 | |
10 | |
7 |