Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

powerbi desktop - Power BI measure totals

I stack now for 3 days and cannot solve the issue - I have PB model where I need to calculate certain values, I created a measure (A+B)*C, it works fine for month dimensions but absolutely wrong with year totals. All the data are from one table. I separated month results from totals, but to get totals I've tried summarize, calculation and all the possible combinations of filters. I repeated variable calc for total. Nothing worked. Finally I got the result good for month for subtotals,totals and items (product subcategory), but for totals cannot get item results , totals and subtotals are ok. Would someone help with this?

Here is the code I am using:

measure1 = VAR A = CALCULATE ( SUM ( 'Tb1'[Value] ), ALL ( 'Tb1'[Products] ), 'Tb1'[Item] = "Item1" ) VAR B = CALCULATE ( SUM ( 'Tb1'[Value] ), ALL ( 'Tb1'[inc/exp] ), 'Tb1'[Item] = "Item2" ) VAR C = CALCULATE ( SUM ( 'Tb1'[Value] ), ALL ( 'Tb1'[Inc/exp] ), 'Tb1'[Item] = "Item3" ) VAR tb2 = CALCULATETABLE ( SUMMARIZE ( 'Tb1', 'Tb1'[Month], "result", ( CALCULATE ( SUM ( 'Tb1'[Value] ), ALL ( 'Tb1'[inc/exp] ), 'Tb1'[Item] = "Item2" ) + CALCULATE ( SUM ( 'Tb1'[Value] ), 'Tb1'[Item] = "Item3" ) ) * CALCULATE ( SUM ( 'Tb1'[Value] ), 'Tb1'[Item] = "Item1" ) ), REMOVEFILTERS ( 'Tb1'[inc/exp], 'Tb1'[Item] ) ) RETURN IF ( HASONEVALUE ( 'Tb1'[Month] ), ( Item2 + Item3 ) * Item1, SUMX ( Tb2, [result] ) )

question from:https://stackoverflow.com/questions/65861639/power-bi-measure-totals

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...