The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I need a measure that will calculate the following condition: if only two atributes D1 and D2 are selected in the slicer, the D1 value (100) should be multiplied (1.25) and then summ with the D2 value (100). Expected value result - 225.
In all other cases, only the Total Value result (for 1 - 100, for 2 - 200, for 3 - 300, for 4 - 400, for all - 500) should be displayed.
Current DAX is not working:
Solved! Go to Solution.
hi @DmitryAD7
Please try this measure
hi @DmitryAD7
Please try this measure
Thanks a lot!
Try this
Sales with Condition =
VAR _select = SELECTEDVALUE ( 'Dataset'[D] )
VAR _d1_value =
CALCULATE ( [Total Value], FILTER ( 'Dataset', 'Dataset'[D] = "D1" ) ) *1.25
VAR _d2_value =
CALCULATE ( [Total Value], FILTER ( 'Dataset', 'Dataset'[D] = "_D2" ) )
VAR _defualt_value =
CALCULATE ( [Total Value], FILTER ( 'Dataset', 'Dataset'[D] = "_select" ) )
VAR Result =
IF ( _select = "D1" && _select = "D2", CALCULATE(_d1_value+_d2_value),_defualt_value)
If it doesn't work, share a sample PBIX file.
Hi @DmitryAD7 ,
Try this:
I have used CONCATENATEX to build a string that contains the values selected in slicer and check if it is equal to "D1, D2"
VAR _select =
CONCATENATEX(
VALUES('Dataset'[D]),
'Dataset'[D],
", "
)
VAR _d1_value =
CALCULATE ( [Total Value], FILTER ( 'Dataset', 'Dataset'[D] = "D1" ) ) * 1.25
VAR _d2_value =
CALCULATE ( [Total Value], FILTER ( 'Dataset', 'Dataset'[D] = "D2" ) )
VAR _default_value =
CALCULATE ( [Total Value], FILTER ( 'Dataset', 'Dataset'[D] = "_select" ) )
VAR Result =
IF (
CONTAINSSTRING(_select,"D1, D2"),
CALCULATE ( _d1_value + _d2_value ),
_default_value
)
RETURN
Result
Sorry, but it still doesn't work.
User | Count |
---|---|
12 | |
9 | |
6 | |
6 | |
6 |
User | Count |
---|---|
24 | |
14 | |
14 | |
9 | |
7 |