Forum Discussion
New Report
- 4 years ago
Hi Anonymous ,
SWITCH function is like a shorthand IF. It is easier to read than having many IF STATEMENTS.Cnpjs IDs/Qty = SWITCH ( SELECTEDVALUE ( Formato[Formato] ), "Qty", [CNPJ compraram com ID], "Volume", [Total_Vol_ID´s] )The above formula tells that if the value selected from Formato column in the Formato table is Qty then it will return the measure [CNPJ compraram com ID] and if volume then [Total_Vol_ID´s]
Total Resellers = SWITCH ( SELECTEDVALUE ( Formato[Formato] ), "Qty", DISTINCTCOUNT ( ChannelDnaReport[POSSoldToCustomerTaxIdRoot] ), "Volume", SUM ( ChannelDnaReport[SellThruProductUnits] ) )The above formula is very similar to the previous one except that instead of refrencing a measure when a value is selected from Formato[Formato], an aggregate expression is used - DISTINCTCOUNT(ChannelDnaReport[POSSoldToCustomerTaxIdRoot]) or SUM(ChannelDnaReport[SellThruProductUnits])
Both formulas will return blank/null if no value is selected from Formato[Formato] unless another condition is added to them to return otherwise.
Hi Anonymous ,
SWITCH function is like a shorthand IF. It is easier to read than having many IF STATEMENTS.
Cnpjs IDs/Qty =
SWITCH (
SELECTEDVALUE ( Formato[Formato] ),
"Qty", [CNPJ compraram com ID],
"Volume", [Total_Vol_ID´s]
)The above formula tells that if the value selected from Formato column in the Formato table is Qty then it will return the measure [CNPJ compraram com ID] and if volume then [Total_Vol_ID´s]
Total Resellers =
SWITCH (
SELECTEDVALUE ( Formato[Formato] ),
"Qty", DISTINCTCOUNT ( ChannelDnaReport[POSSoldToCustomerTaxIdRoot] ),
"Volume", SUM ( ChannelDnaReport[SellThruProductUnits] )
)The above formula is very similar to the previous one except that instead of refrencing a measure when a value is selected from Formato[Formato], an aggregate expression is used - DISTINCTCOUNT(ChannelDnaReport[POSSoldToCustomerTaxIdRoot]) or SUM(ChannelDnaReport[SellThruProductUnits])
Both formulas will return blank/null if no value is selected from Formato[Formato] unless another condition is added to them to return otherwise.