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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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