Forum Discussion

apple43's avatar
apple43
Frequent Visitor
1 year ago

Count within a baseline

Hi Community, 

 

I have following situation: 

 

I need to have a measure that gives me number of sales that are within specific baseline. 

See below an example: 

SellerQtyProductCountryPrice per unitBaseline (price per unit)Total SalesCommissionTotal Comission
Jane60ABR5,563302%6,6
John30AGB6,571952%3,9
Anne20BGB7,56,5150No 
John15BGB6,97103,502%2.07
Peter75BBR6,56487,5No 

 

Correct Asnwer show be = 105 units

 

There are different baselines with combination: Product+Country

 

I have tried to flag whenever Price per unit <= Baseline, Then 1. But when I apply  to a Visual a filter where flag=1, does not list anything.  

 

Can you help me?

 

Thank you!

4 Replies

  • Hello apple43 ,

    Could you please share your demo ppix and your dax code?

    Kind Regards,
    Gรถkberk UzuntaลŸ

    ๐Ÿ“Œ If this post helps, then please consider Accepting it as a solution and giving Kudos โ€” it helps other members find answers faster!

    ๐Ÿ”— Stay Connected:
    ๐Ÿ“˜ Medium |
    ๐Ÿ“บ YouTube |
    ๐Ÿ’ผ LinkedIn |
    ๐Ÿ“ท Instagram |
    ๐Ÿฆ X |
    ๐Ÿ‘ฝ Reddit |
    ๐ŸŒ Website |
    ๐ŸŽต TikTok |

  • GiuseppeMR's avatar
    GiuseppeMR
    Frequent Visitor

    Hi ,

    Try this:

     

    Measure =

    Calculate(

       Sum(qty),

       "Unit price" <= "baseline"

    )

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi apple43 

     

    Thanks for the reply from uzuntasgokberk and GiuseppeMR .

     

    Is this the desired outcome you want? Please refer to the test below. 

     

    Sample data:

    I used some of the sample data you showed. I want to confirm with you whether these data are original data. If there are calculated columns or measures, we need you to show the corresponding formulas to better reproduce your scenario.

     

    Create a measure as follows

     

    Measure = CALCULATE(SUM('Table'[Qty]), FILTER('Table', 'Table'[Price per unit] <= 'Table'[Baseline (price per unit)]))

     

     

    Best Regards,
    Yulia Xu

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • apple43's avatar
      apple43
      Frequent Visitor

      Hi Anonymous , 

       

      Your suggestion is not working! 

      Regarding information about data: 

      - Qty (measure) - table1[qty]  =  CALCULATE([Qty], Product[Product]= "A"|| Product[Product]= "B")

      - price per unit (measure) - table2[Price per unit] (DirectQuery)

      - baseline (measure) - table3[baseline] (DirectQuery)

       

      Neither are calculated columns. 

       

      Thanks in advance!