PowerBI-具有多个条件的累积总计 [英] PowerBI - Cumulative Total with Multiple Criteria

查看:1622
本文介绍了PowerBI-具有多个条件的累积总计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PowerBI的新手,请原谅我的描述。我正在使用零售人数传感器的数据集,它为我提供了位置,时间戳和购物者数量的表:

New to PowerBI, so forgive me for the description here. I'm working with a dataset of retail headcount sensors, which gives me a table of locations, timestamps, and a count of shoppers:

Room     TimeStamp     Count_In
123      3/13/2019     8
456      4/4/2019      9
123      3/28/2019     11
123      3/18/2019     11
456      3/22/2019     3
etc...

我是试图计算一段时间内每个房间的运行总计。总体运行总计列很容易:

I'm trying to calculate a running total for each "room" over time. The overall running total column is easy:

C_In =
CALCULATE (
    SUM ( Sheet1[In] ),
    ALL ( Sheet1 ),
    Sheet1[Time] <= EARLIER ( Sheet1[Time] )
)

但是我无法弄清楚如何添加第二个过滤器,请确保只对每个不同的位置求和。

But I'm unable to figure out how to add that second filter, making sure that I'm only summing for each distinct location. Help is appreciated!

推荐答案

您的 ALL 函数将删除 Sheet1 ,请尝试使用 ALLEXCEPT 保留 Room 。

Your ALL function removes all context on Sheet1, try using ALLEXCEPT to keep the row context of the Room.

C_In =
CALCULATE (
    SUM ( Sheet1[In] ),
    ALLEXCEPT ( Sheet1, Sheet1[Room] ),
    Sheet1[Time] <= EARLIER ( Sheet1[Time] )
)

这篇关于PowerBI-具有多个条件的累积总计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆