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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

between date slicer to get two turnovers based on price start end vs price en date

Dear all,

 

I read a lot of posts but I couldn't find any similar situation to help me.

 

I created a dummy dataset in order to explain my expected result.

 

I got thoses tables which should be self-explanatory 

 

aso_be_0-1663227023622.png

 

And here is the expected result with explanation

aso_be_2-1663227704216.png

 

- start_price : looks for the price of the id at the start date (red) within the PRICE TABLE + total (which is the average of the above column)

- start_price : looks for the price of the id at the end date (green) within the PRICE TABLE + total (which is the average of the above

- quantity_sold : quantity sold for that period within SALES TABLE + total (which is the sum of the above column)

- turnover_start_date_price : is the quantity_sold multiply by the start_price + total (which is the sum of the above column)

- turnover_end_date_price : is the quantity_sold multiply by the end_price+ total (which is the sum of the above column) 

 

I was able to get every data right EXCEPT the total which is not the right amount !

 

You can download this dummy file here : https://docs.google.com/spreadsheets/d/1bJ6QMG2ui1iy9OHSU2A9NDfe7d6ajL2-/edit?usp=sharing&ouid=10108...

 

Thank you in advance for your precious help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Weirdly, I was not able to reproduce it with my real pbix. But thanks to your attempt, I could find a working way to get the right measures.


I actually missed VALUES('PRODUCT TABLE'[id]) from purchase_price_start_date which seemed to be the reason why my total was wrong.



- start_price = CALCULATE (AVERAGE('PRICE TABLE'[price]),'PRICE TABLE[price_date]=MIN('CALENDAR TABLE'[date]))
- end_price =CALCULATE (AVERAGE('PRICE TABLE'[price]),'PRICE TABLE[price_date]=MAX('CALENDAR TABLE'[date]))
- quantity_sold = CALCULATE(SUM(SALES TABLE[sales_quantity]))

- purchase_turnover_start_date =
    SUMX(VALUES('PRODUCT TABLE'[id]),
        [start_price ] * [quantity_sold]
    )
- purchase_turnover_start_date =
    SUMX(VALUES('PRODUCT TABLE'[id]),
        [end_price ] * [quantity_sold]
    )

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Weirdly, I was not able to reproduce it with my real pbix. But thanks to your attempt, I could find a working way to get the right measures.


I actually missed VALUES('PRODUCT TABLE'[id]) from purchase_price_start_date which seemed to be the reason why my total was wrong.



- start_price = CALCULATE (AVERAGE('PRICE TABLE'[price]),'PRICE TABLE[price_date]=MIN('CALENDAR TABLE'[date]))
- end_price =CALCULATE (AVERAGE('PRICE TABLE'[price]),'PRICE TABLE[price_date]=MAX('CALENDAR TABLE'[date]))
- quantity_sold = CALCULATE(SUM(SALES TABLE[sales_quantity]))

- purchase_turnover_start_date =
    SUMX(VALUES('PRODUCT TABLE'[id]),
        [start_price ] * [quantity_sold]
    )
- purchase_turnover_start_date =
    SUMX(VALUES('PRODUCT TABLE'[id]),
        [end_price ] * [quantity_sold]
    )
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yadongf-msft
Community Support
Community Support

Hi @Anonymous ,

 

I think this is result you want:

vyadongfmsft_0-1663550423339.png

 

Please try following DAX:

Start price = IF(
    ISINSCOPE('Price table'[id]),
    CALCULATE(MIN('Price table'[price]),FILTER(ALLSELECTED('Price table'[price_date]),'Price table'[price_date] = MIN('Price table'[price_date]))),
    CALCULATE(AVERAGE('Price table'[price]),FILTER(ALLSELECTED('Price table'[price_date]),'Price table'[price_date] = MIN('Price table'[price_date])))
    )

End price = IF(
    ISINSCOPE('Price table'[id]), 
    CALCULATE(MAX('Price table'[price]),FILTER(ALLSELECTED('Price table'[price_date]),'Price table'[price_date] = MAX('Price table'[price_date]))),
    CALCULATE(AVERAGE('Price table'[price]),FILTER(ALLSELECTED('Price table'[price_date]),'Price table'[price_date] = MAX('Price table'[price_date])))
    )

Quantity_sold = CALCULATE(SUM('Sales table'[sales_quantity]),FILTER('Sales table','Sales table'[sales_date] IN VALUES('Price table'[price_date])))

Quantity_sold2 = SUM('Sales table'[sales_quantity]) - CALCULATE(SUM('Sales table'[sales_quantity]),FILTER('Sales table','Sales table'[sales_date] = MAX('Sales table'[sales_date])))

turnover_start_date_price = IF(
    ISINSCOPE('Price table'[id]),
    [Start price]*[Quantity_sold],
    SUMX(FILTER('Price table','Price table'[price_date] = MIN('Price table'[price_date])),[Start price]*[Quantity_sold2])
    )

turnover_end_date_price = IF(
    ISINSCOPE('Price table'[id]),
    [End price]*[Quantity_sold],
    SUMX(FILTER('Price table','Price table'[price_date] = DATE(2022,1,3)),[Start price]*[Quantity_sold2])
    )

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yadongf-msft
Community Support
Community Support

Hi @Anonymous ,

 

The relationship between two tables:

vyadongfmsft_0-1663311109139.png

 

Please try following DAX:

 

Start price = CALCULATE(MIN('Price table'[price]),FILTER(ALLSELECTED('Price table'[price_date]),'Price table'[price_date] = MIN('Price table'[price_date])))

End price = CALCULATE(MAX('Price table'[price]),FILTER(ALLSELECTED('Price table'[price_date]),'Price table'[price_date] = MAX('Price table'[price_date])))

Quantity_sold = CALCULATE(SUM('Sales table'[sales_quantity]),FILTER('Sales table','Sales table'[sales_date] IN VALUES('Price table'[price_date])))

turnover_start_date_price = [Start price]*[Quantity_sold]

turnover_end_date_price = [End price]*[Quantity_sold]

 

 

The result you want:

vyadongfmsft_1-1663311285315.png

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @v-yadongf-msft,

 

Thanks for your quick answer.

Unfortuanly the total is not right 😞

 

You got that result

 

aso_be_0-1663316361374.png

 

But we should see those numbers 🙂

 

aso_be_2-1663316474871.png

 

 

Do you have an alternative solution? Does someone else?

 

Thanks again 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.