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
Anonymous
Not applicable

Have a complex DAX challenge and need some advise how to solve it

have challenge in Power BI constructing what you see in the picture below. Briefly explained, I need to be able to trace the fish. The fish stocking will be put into cages but here we will also put them into what we call fishgroups. A fishgroup is just a defined period of time the fish stay in the group (start,end). For each day we count how many fish is still alive. After a while the fish is growing and must be sorted and new fish groups are created. In the picture there are 4 fishgroups where fish first is put into FG1 and FG3. After 5 days, FG1 is sorted and 60% is sent to FG2 and 40% sent to FG4. In FG3 is all fish moved to FG4. FG1 and FG3 ends here. FG2 ends when fish are sold. The same happends later for FG4. This is only a brief example. There can be many more sorting. Performance can be an issue. My first thoughts were to create data model with a fact table called BiomassView. It has a relationship M:1 to FishGroupView. We need a way to calculate the weighted numbers, so I created a bridge table to manage that a fishgroup is related to other fishgroups.

 

What I need help to is to construct a DAX Measure that when summarize on each day you get what you see in the End of Day column. When adding Fishgroups to the visualization, you will see how fish are related to fishgroups in separate columns but still the daily sum should be correct. As you seem the spilt operation is happen later on the day, but latest timestamp per day per fishgroup is thing here. In row 8 FG1 shows but it is splitted into FG2 and FG4, It still should be displayed. FG2 should display FG1*0,6, while FG4 should show FG1*0,4 + FG3*1 and the end sum for the day should be FG1*0,6,+ FG1*0,4 + FG3*1 (or FG2+FG4 if stored)

pic.png

 

Below you see my data model using a brigde table to handle many-may relationhip between the fishgroups. I also have the Power BI file if someone is interested to look at it. Perhaps that will be more easy. You can download it from here https://1drv.ms/u/s!AnHMZqeRJMuloW_-10_HFKatGPwu?e=FNK48d

datamodel.png

Hopefully someone can give me some hints here. Perhaps I can do something with my data model that will ease the problem. I am open for everything. Once again thank you for spending your time

 

Regards Geir 

2 REPLIES 2
Anonymous
Not applicable

Hi again and tknaks for the answers. Perhaps I need to explain how this should work. Below I have written out the content of the tree important tables (small amount of data of course)

 

Let us start what is happen. When the fish is put out it will create the first Fish Group row in the FishGroup dimension, the start date will be known, it will create a row in the fact table saying 1000 fish are in stock. It will also create a row in the bridge table saying the qty factor is 1 where destination FG and source FG are the same. The next days the number of fish in stock changes giving new status in the fact table but the calculation has the same factor.

 

The 2.1.2019 we are setting out 1000 fish into FG3, a new row is inserted to fishgroup table, likewise to a new row into the fact table and also the bridge table with qty factor 1 and dest and source fishgroup are the same.

 

Everything goes as normal until we are coming to 5.1.2019 (dd.mm.yyyy), things change. Two new fishgroups are created FG2 and FG4. We are splitting out fishgroup 1 sending 60% of the content to FG2 and 40% to FG4. Likewise is 100% of FG3 sent to FG4. The interesting thing here is what is happening in the bridge table. Destination FG 2 has 60% of content from FG1, but also 100% of its self. FG4 has 40%of the content of FG1 and has 100% of content of FG3 and 100% of itsself. In a report from 1.1.2019 to 4.1.2019 only fishgroup 1 and 3 will be in it. if the report will span from 1.1.2019 to 11.01.2019 all fishgroups will be in it, but the measure must find the right number of fish. There must not be any double counting as can be in the 5.1.2019. And the last timestamp each day is the only valid.

 

I hope this scenario can help to understand the problem I have

 

Fact Table

Date KeyCage KeyFishgroup KeyStatusTimeNumberOfFishStatusType
201901011101/01/2019 12:0010000
201901021102/01/2019 00:009901
201901031103/01/2019 00:009801
201901041104/01/2019 00:009701
201901051105/01/2019 00:009601
201901051105/01/2019 12:009552
201901051205/01/2019 12:005730
201901061206/01/2019 00:005681
201901071207/01/2019 00:005581
201901081208/01/2019 00:005481
201901081208/01/2019 12:005432
201901022302/01/2019 12:0010000
201901032303/01/2019 00:009851
201901042304/01/2019 00:009701
201901052305/01/2019 00:009551
201901052305/01/2019 12:009482
201901052405/01/2019 12:0013300
201901062406/01/2019 00:0013201
201901072407/01/2019 00:0013101
201901082408/01/2019 00:0013001
201901092409/01/2019 00:0012901
201901102410/01/2019 00:0012801
201901112411/01/2019 00:0012701
201901112411/01/2019 12:0012652

 

FishGroup Dimension Table

FishGroup KeyCage KeyStartTimeEndTimeFishgroupNameFishGroup Start Date KeyFishGroup End Date KeyIsDelivery
1101/01/2019 12:0005/01/2019 12:00B-001.00000120190101201901060
2105/01/2019 12:0008/01/2019 12:00B-001.00000220190105201901091
3202/01/2019 12:0005/01/2019 12:00B-001.00000320190102201901060
4205/01/2019 12:0011/01/2019 12:00B-001.00000420190105201901121

 

TraceBack Bridge Table

Qty FactorDestination FishGroup KeySource FishGroup Key
111
0.621
122
133
0.441
143
144
Greg_Deckler
Community Champion
Community Champion

I may be mistaken but I think you want something like my time interval quick measures. Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors
Top Kudoed Authors