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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

In DAX how to filter table1 value&sum is calculated only if table2 boolen value set during period

Hi all!

I've been few days already tried sort this issue with no success (not even from chat GPT;)

 

I have an action table2, from which I try to use trigger "sold" to calculate dividents from another table1 only if stock sold on same period. I have linked tables stocks, dates

 

table2

datestypestockprice
1.1.2022soldalpha100
11.1.2022buybeeta200
21.1.2022buygamma300
1.1.2023soldbeeta100
11.1.2023soldalpha300

 

and table1 I use to sum dividents in various way

datesstockdividen
21.1.2022alpha10
31.1.2022beeta20
10.2.2022gamma30
20.2.2022zorro20
2.3.2022zeta20
21.1.2023alpha10
21.1.2023beeta20
31.1.2023gamma30
10.2.2023zorro20
20.2.2023zeta20

 

 

In BI I can summarize OK all stocks "sold" and dividends in given period, but calculating in another measure dividents of only sold stocks fails

 

yearstocksold valueall dividentssold dividents
2022 sum 100100this sum dont work
2022alpha1001010
2022beeta 20 
2022gamma 30 
2022zorro 20 
2022zeta 20 
2023 sum 200 this sum dont work
2023alpha3001010
2023beeta1002020
2023gamma 30 
2023zorro 20 
2023zeta 20 

 

I manage to create in table2 a boolean if stock sold, but do not know how to apply it properly. E.g. the sum of sold stocks dividents is either empty or sums erroneously all sold stocks dividents during all years.

e.g. to count sum of sold stocks I use: soldprice= CALCULATE(SUM('table1'[price]),filter(all('table1[Type]),('table1'[Type]="sold")))

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Anonymous Not sure, but first, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks Greg for long list of reading, I seem to be too inexperienced with BI. I cannot get none of these working, I trieed to create shareable simple BI with my sample data but got stuck  with other basics before able to try solutions. I tried in my original data which somewhat works , but only simple m_single formula worked Measure Totals, The Final Word - Microsoft Power BI Community

 

another suggestion Dealing with Measure Totals - Microsoft Power BI Community I added in my sample excel and BI but again the key formula "MyMeasure2" failed, has BI changed that much sionce 2016 POSTED?

 

mymeasure2.jpgstocksample.jpg

 

but since cannot upload files probably too difficult explain, I need re-take all trainings I took years back and forgot everything as did not apply for long time

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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