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

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.

Reply
dwhittaker1
Helper I
Helper I

Help understanding Measure

Can anyone help me understand the below measure. My interpretation is
if Price per unit -PY$ is blank then sum where Price per unit - PY$ is greater than 0. I dont uderstand the rest.
 
Price Impact - Sales - CY vs PY $ =
IF(
    [Price per Unit - PY $]=BLANK(),
        BLANK(),
        SUMX(
            FILTER(
                ALL(  FactSalesInvoiceLine[InvoiceItemID],FactSalesInvoiceLine[InvoiceMonth] ),
                [Price per Unit - PY $] > 0
                ),
            CALCULATE([Unit Quantity - CY]*[Price per Unit - CY vs PY $])
        )
)
1 ACCEPTED SOLUTION
audreygerred
Super User
Super User

This DAX expression is used to calculate a value based on certain conditions. Here's how it works:

  1. It first checks if the column [Price per Unit - PY $] is blank. If it is, the result is also set to blank, and the calculation stops. This condition handles cases where the price for the previous year is missing or not available.

  2. If the [Price per Unit - PY $] is not blank, it proceeds to the next step. It filters the data in the table FactSalesInvoiceLine based on the following conditions:

    • It considers all rows but filters them down to those where [Price per Unit - PY $] is greater than 0.
    • The filtering is applied to two columns: [InvoiceItemID] and [InvoiceMonth].
  3. For the filtered rows, it performs a calculation. It multiplies the values in the columns [Unit Quantity - CY] and [Price per Unit - CY vs PY $].

  4. Finally, it sums up the results of these calculations for all the filtered rows, providing the final result.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

1 REPLY 1
audreygerred
Super User
Super User

This DAX expression is used to calculate a value based on certain conditions. Here's how it works:

  1. It first checks if the column [Price per Unit - PY $] is blank. If it is, the result is also set to blank, and the calculation stops. This condition handles cases where the price for the previous year is missing or not available.

  2. If the [Price per Unit - PY $] is not blank, it proceeds to the next step. It filters the data in the table FactSalesInvoiceLine based on the following conditions:

    • It considers all rows but filters them down to those where [Price per Unit - PY $] is greater than 0.
    • The filtering is applied to two columns: [InvoiceItemID] and [InvoiceMonth].
  3. For the filtered rows, it performs a calculation. It multiplies the values in the columns [Unit Quantity - CY] and [Price per Unit - CY vs PY $].

  4. Finally, it sums up the results of these calculations for all the filtered rows, providing the final result.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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