The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello everyone,
I have a situation where in my fact table there are no entries for a given month. However, in the graph visualization, I still would like to see this months with 0 as a value.
Relevant of information regarding my model:
Dim Date: contains a typical date dimension. Based on a interval (7/1/2012 - 12/31/2022), I have a continous date period in a daily basis.
Dim Product: contains information about the product.
Dim Company: contains information regarding the corresponding subsidiary.
Fact: contains the sales of a given product per month and company.
Particularities:
Example:
Month Year | Company ID | Product ID | Qty | Date |
201301 | 2500 | 97858697 | 10 | 1/1/2013 |
201402 | 2500 | 97858697 | 5 | 2/1/2014 |
201501 | 2500 | 97858697 | 5 | 1/1/2015 |
201502 | 2500 | 97858697 | 10 | 2/2/2015 |
Power BI standard visualization:
I saw that there is the possibility to configure the graph to show items with no data. In order to that, I even filtered my Dim Date to only show the first of each month since the fact table is in a monthly bases and I did not want more 0s than required. However, this made no difference at all. The visualization was exact the same.
Then, i created a measure to fill in the places missing data:
Qty with 0s = if (ISBLANK(SUM('Fact'[Qty])),0,SUM('Fact'[Qty]))
This worked better but still not as I want. I want to have the line draw only from the first month available in the fact table (July of 2012) until the last month available in the fact table (December 2022), independent of the product itself.
Is it possible to add this condition in the measure?
I am not sure how to do that.
In the link below you can find a DUMMY example.
Thank you very much.
Solved! Go to Solution.
Hi @jessicarocha ,
Try this:
Qty with 0s =
VAR mDate = CALCULATE( MAX( 'Fact'[Date] ) , ALL( 'Fact' ) )
Return
IF( SELECTEDVALUE('Dim Date'[Date]) < mDate ,
SUM('Fact'[Qty]) +0 , BLANK()
)
hi @jessicarocha Please review the attached file and tell me if this is your expected result
Hi @DimaMD . Thank you very much for taking the time to help with my problem. I had already used the solution suggested by tex628. That's why I can't accept your reply as the solution. But thank you!
You guys had the same idea for the formula. It definetely works!
Hi @jessicarocha ,
Try this:
Qty with 0s =
VAR mDate = CALCULATE( MAX( 'Fact'[Date] ) , ALL( 'Fact' ) )
Return
IF( SELECTEDVALUE('Dim Date'[Date]) < mDate ,
SUM('Fact'[Qty]) +0 , BLANK()
)
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
82 | |
76 | |
46 | |
39 |
User | Count |
---|---|
135 | |
109 | |
70 | |
64 | |
55 |