以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  有点麻烦的计算问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=109231)

--  作者:fubblyc
--  发布时间:2017/11/7 12:37:00
--  有点麻烦的计算问题
老师,我这个表要算断码率,公式是:
断码率 = 有销售的尺码没有库存的尺码个数/有销售的尺码个数
举例:
下图中,
门店 大沥一,
没有库存的尺码个数为1个(28码库存=0)/ 有销售的尺码个数为7个(除了34码的没有销售)= 1/7
门店 大沥二,
没有库存的尺码个数为2个(33 、36库存=0,虽然28也没有库存,但是也没有销售,所以不算断码)/ 有销售的尺码个数为4个(尺码31 、32 、33 、36)= 2/4

图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20171107123833.png
图片点击可在新窗口打开查看



[此贴子已经被作者于2017/11/7 12:38:49编辑过]

--  作者:有点甜
--  发布时间:2017/11/7 13:07:00
--  

比如

 

(iif(库存_28=0 and 销售_28<>0, 1, 0) + iif(库存_29=0 and 销售_29<>0, 1, 0)) / (iif(销售_28>0, 1, 0) + iif(销售_29>0, 1, 0))

[此贴子已经被作者于2017/11/7 13:07:48编辑过]

--  作者:fubblyc
--  发布时间:2017/11/7 15:45:00
--  
谢谢甜老师!
是这样,
列名字是 
销售数量_1,销售数量_2...
库存数量_1,库存数量_2...
我们看到的是列标题:
销售数量_28
库存数量_28
销售数量_1 和库存数量_1 有时候并不是都是指同一个码。所以只能通过列标题去对应


我之前是这样写:
Dim xsgs As Integer = 0    \'有销售的尺码个数
Dim kcgs As Integer = 0    \'有销售没有库存的尺码个数
Dim cap2 As String
Dim cap3 As String
For Each r2 As Row In Forms("AA").Controls("table2").Table.Rows
    For Each c2 As Col In Forms("AA").Controls("table2").Table.Cols
        If c2.Caption.Contains("销售数量_") And c2.Caption.Contains("店仓名称") = False Then
            If r2(c2.name) > 0  Then
                xsgs = xsgs + 1
                cap2 = c2.Caption.Replace("销售数量_","")                
            End If
        End If
    Next
Next

上面是算出了有销售的个数了,但不知道怎么算有销售的尺码中,几个是没有库存的

For Each c3 As Col In Forms("AA").Controls("table2").Table.Cols
    If c3.Caption.Contains("可用库存_") And c3.Caption.Contains("店仓名称") = False Then
        If r3(c3.name) = 0  Then
            kcgs = kcgs + 1
            cap3 = c3.Caption.Replace("可用库存_","")
        End If
    End If
Next
[此贴子已经被作者于2017/11/7 15:47:50编辑过]

--  作者:有点甜
--  发布时间:2017/11/7 16:33:00
--  

Dim dic_xl As new Dictionary(Of String, String)
Dim dic_kc As new Dictionary(Of String ,String)
For Each c2 As Col In Forms("AA").Controls("table2").Table.Cols
    If c2.Caption.Contains("销售数量_") And c2.Caption.Contains("店仓名称") = False Then
        Dim v  = c2.Caption.Replace("销售数量_","")
        dic_xl.add(v, c2.name)
    End If
    If c2.Caption.Contains("可用库存_") And c2.Caption.Contains("店仓名称") = False Then
        Dim v  = c2.Caption.Replace("可用库存_","")
        dic_kc.add(v, c2.name)
    End If
Next

For Each r2 As Row In Forms("AA").Controls("table2").Table.Rows
    Dim count1 As Integer = 0
    Dim count2 As Integer = 0
    For Each key As String In dic_xl.Keys
        If r2(dic_xl(key)) > 0 Then \'
            count1 += 1
            If r2(dic_kc(key)) = 0 Then
                count2 += 1
            End If
        End If
    Next
    If count1 > 0 Then
        r2("断码率") = count2 / count1
    else
        r2("断码率") = nothing
    end if
   
Next


--  作者:fubblyc
--  发布时间:2017/11/7 17:55:00
--  
厉害了,无所不能的甜老师!!!