Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
在用PowerBI做数据分析时,我希望自己的数据是以“每天”的日期颗粒度来记录和存储的。
因为PowerBI的运行逻辑,是先用筛选器筛选出目标数据,然后在筛选出的数据的基础上,进行分析和计算。
比如我有100名员工,我希望能在2025年的“某一天”计算公司的【在职人数】,那意味着我要在365天的每一天都要录入100行数据,这个Excel表中全年总计需要存储100*365数据,以方便不定期的筛选。
如果我有1万名员工,那这个数据量将剧增至365万行,这太可怕了。
我想知道,是否有更“巧妙的”数据存储方式,既满足“每天颗粒度”的筛选,又不至于有这么大数据量?
Hi @simonwilson -Instead of storing millions of rows, use a measure like this. Hope you already have a date table .
so that you can use the max date and as per selected the values or numbers should display.
Active Employees =
VAR _SelectedDate = MAX('Date'[Date]) -- Get the selected date
RETURN
CALCULATE(
COUNT(Employee[EmployeeID]),
Employee[StartDate] <= _SelectedDate, -- Employees who have joined
OR(ISBLANK(Employee[EndDate]), Employee[EndDate] >= _SelectedDate) -- Employees who haven’t left yet
)
This way, Power BI dynamically calculates the active employees on any selected date without needing millions of rows.
Hope this helps.
Proud to be a Super User! | |
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
145 | |
73 | |
63 | |
52 | |
51 |
User | Count |
---|---|
208 | |
91 | |
62 | |
59 | |
56 |