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

The 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.

Reply
simonwilson
New Member

PowerBI Excel数据源的存储优化问题

在用PowerBI做数据分析时,我希望自己的数据是以“每天”的日期颗粒度来记录和存储的。

因为PowerBI的运行逻辑,是先用筛选器筛选出目标数据,然后在筛选出的数据的基础上,进行分析和计算。

 

比如我有100名员工,我希望能在2025年的“某一天”计算公司的【在职人数】,那意味着我要在365天的每一天都要录入100行数据,这个Excel表中全年总计需要存储100*365数据,以方便不定期的筛选。

如果我有1万名员工,那这个数据量将剧增至365万行,这太可怕了。

 

我想知道,是否有更“巧妙的”数据存储方式,既满足“每天颗粒度”的筛选,又不至于有这么大数据量?

1 REPLY 1
rajendraongole1
Super User
Super User

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.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.