首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Power BI 分组TopN排名表格

Power BI 分组TopN排名表格

作者头像
wujunmin
发布2025-09-03 18:47:25
发布2025-09-03 18:47:25
1440
举报
文章被收录于专栏:wujunminwujunmin

效果如下图所示,展示每个店铺的Top3业绩员工:

这里使用了DAX结合HTML制作表格,表格度量值如下:

代码语言:javascript
复制
HTML.业绩看板.静态 = 
"
<head>
   <style>
        .container {
            max-width: 1000px;
            margin: 0 auto;
            background: white;
            border-radius: 10px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }
        
        .department {
            font-weight: bold;
            color: #0d47a1;
            width: 20%; 
        }
        .table-container {
            padding: 20px;
            overflow-x: auto;
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
            table-layout: fixed; 
        }
        
        th, td {
            padding: 16px 20px;
            text-align: left;
            border-bottom: 1px solid #e0e0e0;
            vertical-align: middle;
        }
        
        th {
            background-color: #e3f2fd;
            font-weight: bold;
            color: #1565c0;
        }
        
        
        
        .stas-list {
            position: relative;
            overflow: hidden;
            height: 60px;
            width: 100%; 
            display: flex;
            align-items: center;
        }
        .sta-item {
            display: inline-flex;
            align-items: center;
            margin-right: 30px;
            background: #e8f4ff;
            padding: 8px 15px;
            border-radius: 20px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
            flex-shrink: 0; 
        }
        
        .sta-number {
            background: #2196f3;
            color: white;
            width: 26px;
            height: 26px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 14px;
            font-weight: bold;
            flex-shrink: 0; 
        }
        
        .sta-name {
            font-size: 16px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }  
  
    </style>
</head> 
<body>
    <div class='container'>
        
        <div class='table-container'>
            <table>
                <thead>
                    <tr>
                        <th class='department'>店铺名称</th>
                        <th>人员业绩排名</th>
                    </tr>
                </thead>
                <tbody>" & CONCATENATEX(VALUES('表'[店铺名称]),
                VAR t =TOPN(3, VALUES(表'[销售员]),[M.销售业绩],DESC)
                RETURN "
                    <tr>
                        <td class='department'>" & [店铺名称] & "</td>
                        <td>
                            <div class='stas-list'>
                                <div class='scroll-container scroll-animation'>" & 
                                CONCATENATEX(t,"
                                    <div class='sta-item'>
                                        <span class='sta-number'>" & ROWNUMBER(t,ORDERBY([M.销售业绩],DESC)) & "</span>
                                        <span class='sta-name'>" & [销售员] & " | " & FORMAT([M.销售业绩],"#,#") & "</span>
                                    </div>" ,,[M.销售业绩],DESC) & "
                                </div>
                            </div>
                        </td>
                    </tr>" ) & "
                </tbody>
            </table>
        </div>
    </div>
</body>"

把度量值放入HTML Content视觉对象即可正常显示。HTML表格在Power BI有很多优势,参考Power BI HTML 表格的四大优势

如果不想展示TopN,而是每家店铺全员展示,可以考虑使用动画滚动:

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2025-09-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 wujunmin 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档