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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
camelia_
Frequent Visitor

how to calculate data with double and same date

hiiii

 

Currently I have this dax function

Relative Price = IF(COUNT('Sample Transactions'[Buy/sell reference])= -1, SUM('Sample Transactions'[Total Trade Price*])-SUM('Price'[PRICE] ), IF(COUNT('Sample Transactions'[Buy/sell reference])=1, -1*(SUM('Sample Transactions'[Total Trade Price*])-SUM('Price'[PRICE])),""))
 
From this fuction, I am able to calculate the relative price, but only when the date is not the same (for example 1/1/22 = 22.31 , 2/1/22 = 22.56 ), but it can't calculate when the values are in the same date ( for example 3/1/22 = 22.45 , 3/1/22 = 23.00)
 
can someone help me? Thanks in advance!
2 REPLIES 2
amitchandak
Super User
Super User

@camelia_ ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak ,I am sorry that i really can't share any of the data, but the problem is that for example

from Sample Transactions excel sheet, i have a list of traded date and price, somewhat like this

Traded dateTraded priceBuy/SellBuy/Sell reference
1/1/2222.56buy1
2/1/2222.5buy1
3/1/2222.0sell-1
3/1/2222.31sell-1
4/1/2223.0buy1

and the market price is from Price excel sheet, from this sheet is just a list of price based on everyday date, no duplicate date

 

so when i put it in power bi, i use the above measure to calculate the relative price, but for same date like the above table, (3/1/22), it come out blank in matrix table visualisation.

 

for creating the matrix table visualisation, i create relationship as below,

Screenshot (11).png

isin with isin (reference > price & sample transactions) , date with date (timeline > price & sample transactions)

do you happen to know how to fix this ?

 

and i have another problem, for relative price & gain/loss, i create function in power bi (like above), but these measure can't be summarized( don't have the summarize category in measure tool>properties),so i can't put these in the card visualisation.

Gain / Loss = IF(COUNT('Sample Transactions'[Buy/sell reference])= -1, SUM('Sample Transactions'[Total Trade Price*])-SUM('Price'[PRICE] ) / SUM('Price'[PRICE]), IF(COUNT('Sample Transactions'[Buy/sell reference])=1, -1*(SUM('Sample Transactions'[Total Trade Price*])-SUM('Price'[PRICE])) / SUM('Price'[PRICE]),""))

How to fix this?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.