Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am not sure how to most effectively write a DAX measure for "amount" that takes both a Scaled value slicer and a currency slicer into account.
SCALE-Table :
SHOW VALUE AS DividedBy
Real Value 1
Thousands 1000
Millions 1000000
Currency-Table
CURRENCY
LCY
DKK
I have create a measure that takes the scaled value into account:
IF ( HASONEVALUE ( Scale[DividedBy] ), DIVIDE (sum('SalesTrans'[Amount]), VALUES ( Scale[DividedBy] ) ) , sum('SalesTrans'[Amount]) )
And a measure that takes currency into account:
IF ( HASONEVALUE ( 'Currency'[Currency] ), SWITCH ( TRUE (), VALUES ( 'Currency'[Currency] ) = "DKK", // If no value set 0 sum('SalesTrans'[Amount]), VALUES ( 'Currency'[Currency] ) = "LCY", sum(SalesTrans[Amount]) ), // Default Value sum(SalesTrans[Amount]) )
How can i most effectively write these measure into one?
If any of the value in the currency or scaled slicer has been selected, I want to show DKK and Real Value as default 🙂
Can anyone help?
Now, i have created a measure based on the onther measure in this way:
IF ( HASONEVALUE ( Scale[DividedBy] ), DIVIDE ( [Amount], VALUES ( Scale[DividedBy] ) ) , [Amount] )
Is this best practices?
Later on, I would like to create a parameter thats hold the different periods, e.g. YTD, YTD LY, FY YTD etc.
as described here: http://www.daxpatterns.com/parameter-table/#skip-to-period-table .
Hi @Anonymous,
You can try to use below to merge these measure to one:
dynamic result= var selected=IF ( HASONEVALUE ( Scale[DividedBy] ), VALUES ( Scale[DividedBy] ),BLANK() ) var result= DIVIDE (sum('SalesTrans'[Amount]), selected, sum('SalesTrans'[Amount])) return IF (HASONEVALUE ( 'Currency'[Currency] ), SWITCH ( max('Currency'[Currency]),"DKK", max(0,result),"LCY",result), result)
>>Later on, I would like to create a parameter thats hold the different periods, e.g. YTD, YTD LY, FY YTD etc.
If you share more detail informations, it will help to writing formula.
In addition, you can also take a look at below link:
Regards,
Xiaoxin Sheng
Unfortunately, I get an error with the divide function:
I have tried duing this, but this is not working either:
// Parent-child hierarchy VAR BrowseDepth = ISFILTERED (Org[Level 1]) + ISFILTERED (Org[Level 2]) + ISFILTERED (Org[Level 3]) + ISFILTERED (Org[Level 4]) + ISFILTERED (Org[Level 6]) // Currency parameter/slicer VAR AmountXX = IF ( HASONEVALUE ( Currency[Currency] ), SWITCH ( TRUE (), VALUES ( Currency[Currency] ) = "DKK", sum(GLTransaction[Amount DKK])*-1, VALUES ( Currency[Currency] ) = "LCY", sum(GLTransaction[Amount LCY])*-1 ), // Default Value sum(GLTransaction[Amount DKK])*-1 ) // ShowValueAs parameter/slicer VAR Amount = IF ( HASONEVALUE ( Scale[DividedBy] ), DIVIDE ( [AmountXX], VALUES ( Scale[DividedBy] ) ) , [AmountXX] ) RETURN //Ensure correct browsing of parent-chrild hierarchy IF ( MAX(Org[OrgNodeLenght]) >= BrowseDepth, Amount*-1 )
// Parent-child hierarchy
VAR BrowseDepth =
ISFILTERED (Org[Level 1]) +
ISFILTERED (Org[Level 2]) +
ISFILTERED (Org[Level 3]) +
ISFILTERED (Org[Level 4]) +
ISFILTERED (Org[Level 6])
// Currency parameter/slicer
VAR AmountXX =
IF (
HASONEVALUE ( Currency[Currency] ),
SWITCH (
TRUE (),
VALUES ( Currency[Currency] ) = "DKK", sum(GLTransaction[Amount DKK])*-1,
VALUES ( Currency[Currency] ) = "LCY", sum(GLTransaction[Amount LCY])*-1
),
// Default Value
sum(GLTransaction[Amount DKK])*-1
)
// ShowValueAs parameter/slicer
VAR Amount =
IF (
HASONEVALUE ( Scale[DividedBy] ),
DIVIDE ( [AmountXX], VALUES ( Scale[DividedBy] ) )
, [AmountXX]
)
RETURN
//Ensure correct browsing of parent-chrild hierarchy
IF (
MAX(Org[OrgNodeLenght]) >= BrowseDepth,
Amount*-1
)
HI @Anonymous,
Please share some sample file for test.
Regards,
Xiaoxin Sheng
@Anonymous
I think your method is pretty solid. How did you calculate amount?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
93 | |
84 | |
66 |