Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Write measure that combines, ScaleValue slicer (ShowValueAs) and with Currency slicer

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?

6 REPLIES 6
Anonymous
Not applicable

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:

DAX: YTD and MTD questions

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Unfortunately, I get an error with the divide function:

 

Capture.PNG

Anonymous
Not applicable

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

@Anonymous

 

I think your method is pretty solid. How did you calculate amount?

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.