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
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
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.

Top Solution Authors