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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
maricci
Regular Visitor

Subtracting values, threading through several tables

Good day everyone,

I am attaching the PowerBi file.https://drive.google.com/file/d/1HWX0sZt1FZ_JnZCnSu9OTAwhhhum8azq/view?usp=sharing 
I don't know how to subtract the values, which in some cases are positive and in others negative. The principle is as follows, from table lib it is calculated for table t1, column 1 line_1+line_3, then it goes to table met. In table met, it is looked at for each month separately, line_1 covers ran 1,2, and line_3 covers ran 1,2,4. Then we go to the fact table and read the values, which are finally added or subtracted. In the fact table, for the month of January, ran 1 = 5, ran 2 = 8....In the end, the calculation looks like this: 5+8+5+8+5 = 31. And so for every month. Here is another example when we also have subtraction. We also go to table lib first, there we read for table t1, column 2 = line_1 - line_3. Now it is minus because the sign is -1, then we go to table met and read what line_1 and line_3 include, that is, which ran. We arrive at the formula 1+2-1-2-4. We go to the fact table to read these values ​​and we get that the result is 5+8-5-8-5 = -5 for the month of January.

Here is a display and table of how the results should look.

 JanuaryFebruaryMarchTotal
t126301268
131351783
2-5-5-5-15
t2-37-43-20-100
1-19-23-9-51
2-18-20-11-49


Thanks in advance.

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @maricci 

Based on your description, I create the following measure.

Measure = sumx(VALUES('met'[line]),SUM('fact'[amount]))
Measure 2 = IF(ISINSCOPE(met[ran]),[Measure],IF(ISINSCOPE(lib[line]),MAX(lib[sign])*[Measure]))
Measure 3 = SUMX(VALUES(lib[line]),[Measure 2])
Measure 4 = SUMX(VALUES(lib[column]),[Measure 3])
Measure 5 = SUMX(VALUES(lib[table]),[Measure 4])

Then put the meaure 5 to the value.

Output

vxinruzhumsft_0-1713252196289.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

View solution in original post

1 REPLY 1
v-xinruzhu-msft
Community Support
Community Support

Hi @maricci 

Based on your description, I create the following measure.

Measure = sumx(VALUES('met'[line]),SUM('fact'[amount]))
Measure 2 = IF(ISINSCOPE(met[ran]),[Measure],IF(ISINSCOPE(lib[line]),MAX(lib[sign])*[Measure]))
Measure 3 = SUMX(VALUES(lib[line]),[Measure 2])
Measure 4 = SUMX(VALUES(lib[column]),[Measure 3])
Measure 5 = SUMX(VALUES(lib[table]),[Measure 4])

Then put the meaure 5 to the value.

Output

vxinruzhumsft_0-1713252196289.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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