我有一个包含:
在各个国家 /地区出售各种水果的帐户,即我正在处理一些指标,我真的想计算一个国家在一个国家的第一批水果与同一国家的最后出售水果之间的时间之间的时间。
例如:“两天之间”在奥地利首次出售了橙色,最后出售了奥地利的橙色,
我已经使用措施解决了这一点,但这不允许我进一步工作,因为这会给我带来循环依赖的错误(所有人)参考!)
我想知道我是否可以这样做不那么复杂?一个想法是在PowerQuery中设置额外的表格,该桌子是由Fruit和Country出售的最新日期,类似于Excel中的Pivot可以做的事情,此后,我可以链接到我的主桌子并使用相关选项来检索日期。
有什么想法吗?
PowerBi中的当前序列:
DURATION =
VAR dispdate =
MIN( 'Test dat'[Dispath] )
VAR lastsoldthiscountry =
CALCULATE(
MAX( 'Test dat'[Last sold date] ),
ALL( 'Test dat' ),
SUMMARIZE( 'Test dat', 'Test dat'[Fruit], 'Test dat'[Country] )
)
RETURN
IF(
NOT ( ISBLANK( lastsoldthiscountry ) ) && NOT ( ISBLANK(dispdate) ),
INT( lastsoldthiscountry - dispdate )
)
Excel原始测试:
PBI文件:PBI文件:
https://www.dropbox.com/s/ljnyics.com/s/ljnyics6d7n744oc/test。 pbix?dl = 0
I have a data set containing:
Accounts selling various fruits in various countries, im working on some metrics and I really want to calculate the time between the first sold fruit in a country to the last sold fruit in the same country.
For instance: "days between" First sold ORANGE in Austria to Last sold ORANGE in AUSTRIA
I have solved this using a measure, which works but this doesn't allow me to work further with it as it throws me error with circular dependicies (ALL reference!)
I wonder if I can do this less complicated? an idea would be to set up an additional table in powerquery having latest date sold by fruit and country similar to what a pivot can do in excel, after that I could link to my main table and retrieve the date by using the RELATED option.
Any ideas?
Current muesure in powerBI:
DURATION =
VAR dispdate =
MIN( 'Test dat'[Dispath] )
VAR lastsoldthiscountry =
CALCULATE(
MAX( 'Test dat'[Last sold date] ),
ALL( 'Test dat' ),
SUMMARIZE( 'Test dat', 'Test dat'[Fruit], 'Test dat'[Country] )
)
RETURN
IF(
NOT ( ISBLANK( lastsoldthiscountry ) ) && NOT ( ISBLANK(dispdate) ),
INT( lastsoldthiscountry - dispdate )
)
Excel raw test:
https://www.dropbox.com/scl/fi/cppyzagm4ahusrxmadlg6/Test_data_withPivot.xlsx?dl=0&rlkey=2nf5wzl7etwr2hqg2lh4oyifx
PBI file:
https://www.dropbox.com/s/ljnyics6d7n74oc/test.pbix?dl=0
发布评论
评论(1)
如果我正确理解您,则可以在电源查询中完全做您想做的事情。
fruit
和country
开始
开始日期max
代码>结束日期法国苹果的负数似乎是由于数据输入错误
如果缺少日期条目,则表将显示一个零,因为PQ如何处理算术操作中的null
If I understand you correctly, you can do what you want entirely in Power Query.
Fruit
andCountry
Min
ofStart Date
andMax
ofEnd Date
The negative number for France Apples seems due to a data entry error
If there is a missing date entry, the table will show a null, due to how PQ processes nulls in arithmetical operations