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.
Dear PBI Community, thank you in advance for the help
I am new to Power BI & DAX
I have tow tables
1) flock table with an initial number of birds.
2) Birds mortality logs
I want to add new colum in mortality log table wich gives the current birds count by subtracting previous mortality
Solved! Go to Solution.
If you want to do it using DAX, you can first create a one to many relationship between the two tables based on flock id in both tables (that will make it much faster and easier)
the create New Column >
Balance No. of Birds =
VAR CurrentID = Mortality[id]
VAR FlockTable =
CALCULATETABLE ( Motality, ALLEXCEPT ( Mortalit, Mortalit[flock_id] ) )
VAR PreviousIDsTable =
FILTER ( FlockTable, Mortality[id] <= CurrentID )
VAR TotalMortality =
SUMX ( PreviousIDsTable, Mortality[mortality] )
VAR FlockPopulation =
RELATED ( Flocks[no_of_birds] )
RETURN
FlockPopulation - TotalMortality
If you want to do it using DAX, you can first create a one to many relationship between the two tables based on flock id in both tables (that will make it much faster and easier)
the create New Column >
Balance No. of Birds =
VAR CurrentID = Mortality[id]
VAR FlockTable =
CALCULATETABLE ( Motality, ALLEXCEPT ( Mortalit, Mortalit[flock_id] ) )
VAR PreviousIDsTable =
FILTER ( FlockTable, Mortality[id] <= CurrentID )
VAR TotalMortality =
SUMX ( PreviousIDsTable, Mortality[mortality] )
VAR FlockPopulation =
RELATED ( Flocks[no_of_birds] )
RETURN
FlockPopulation - TotalMortality
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
58 | |
50 | |
44 | |
19 | |
19 |