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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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.

@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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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