Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
I'm in a tricky situation where I'm trying to find "on how many days a particular sale type appeared in the selected time period".
Report uses 3 fields.
Dim_Date[DateAlternateKey] -> Connected to Fact_Sales with DateKey
Dim_Item[Store Item Id] -> Connected to Fact_Sales with ItemIdentificationKey
Fact_Sales[Sale Type] -> A field value where the particular item is sold on Normal sale / Special 1 / Special 2 / Special 3 / Markdown sale.
An item with Store Item Id = 09300617065876 is sold in the store on below days in "December 2020" on the mentioned Sale Type.
Now I want to find out the 3rd column below which is mentioned in the subject.
I tried below measures but it did not work.
Count := CALCULATE(DISTINCTCOUNT(Fact_Sales[Sale Type]);
Count := CALCULATE(COUNT(Fact_Sales[Sale Type])
Could you please help me in correcting the measure.
Thank you in advance.
Solved! Go to Solution.
Please try this measure expression.
Days with Sales = DISTINCTCOUNT(Fact_sales[DateKey])
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Please try this measure expression.
Days with Sales = DISTINCTCOUNT(Fact_sales[DateKey])
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thank you very much Pat.
It appears to be working.
Now, I'm heading to actual business problem i.e. on how many days, the item was on the "sale type of last sold" in the selected time period".
In this case, I'm trying to check the result with hard-coded Sale Type
CALCULATE(CALCULATE(DISTINCTCOUNT(Dim_Date[DateKey]), Fact_Sales),FILTER (ALL(Fact_Sales[Sale Type]),Fact_Sales[Sale Type] = "Special 3"))
The above formula seems to be working.
But it would be great if you could help me with a better way of wiriting it.
Thank you in advance.
Hi @Laxman
When using CALCULATE you need an expression and a filter.
Example:
Count := CALCULATE(COUNTROWS(Fact_Sales[Sale Type]) , Filter('Fact_Sales',Fact_Sales[Sale Type]="Special 2"))
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook
Thank you AJ.
I tried the above formula. But it shows below error
"Semantic Error: A single value for column 'Sale Type' in table 'Fact_Sales' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."
It could be because on a particular day, the item was sold in multiple transactions on the specified Sale Type.
Could you please help me know if there is a way to fix it.
Thanks in advance
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
99 | |
72 | |
44 | |
38 | |
30 |
User | Count |
---|---|
157 | |
90 | |
62 | |
46 | |
40 |